examples/event-test: Use atexit for Python 3
Assigning sys.exitfunc no longer works with Python 3. Use atexit.register() instead. Signed-off-by: shechenglong <shechenglong@xfusion.com>
This commit is contained in:
parent
a6e7c332ee
commit
10f36cfb6f
55
examples-event-test-Use-atexit-for-Python-3.patch
Normal file
55
examples-event-test-Use-atexit-for-Python-3.patch
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
From cb8cceb0d8498bf0e2595a0830ab253afc3d64c7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Philipp Hahn <hahn@univention.de>
|
||||||
|
Date: Mon, 27 Apr 2020 14:57:04 +0200
|
||||||
|
Subject: [PATCH 001/297] examples/event-test: Use atexit for Python 3
|
||||||
|
|
||||||
|
Assigning sys.exitfunc no longer works with Python 3.
|
||||||
|
|
||||||
|
Use atexit.register() instead.
|
||||||
|
|
||||||
|
Signed-off-by: Philipp Hahn <hahn@univention.de>
|
||||||
|
---
|
||||||
|
examples/event-test.py | 8 +++-----
|
||||||
|
1 file changed, 3 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/examples/event-test.py b/examples/event-test.py
|
||||||
|
index 0bebf23..7a73da5 100755
|
||||||
|
--- a/examples/event-test.py
|
||||||
|
+++ b/examples/event-test.py
|
||||||
|
@@ -6,6 +6,7 @@
|
||||||
|
# Start off by implementing a general purpose event loop for anyone's use
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
+import atexit
|
||||||
|
import sys
|
||||||
|
import getopt
|
||||||
|
import os
|
||||||
|
@@ -15,6 +16,7 @@ import errno
|
||||||
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
|
+
|
||||||
|
# This example can use three different event loop impls. It defaults
|
||||||
|
# to a portable pure-python impl based on poll that is implemented
|
||||||
|
# in this file.
|
||||||
|
@@ -776,16 +778,12 @@ def main():
|
||||||
|
vc = libvirt.openReadOnly(uri)
|
||||||
|
|
||||||
|
# Close connection on exit (to test cleanup paths)
|
||||||
|
- old_exitfunc = getattr(sys, 'exitfunc', None)
|
||||||
|
-
|
||||||
|
def exit():
|
||||||
|
print("Closing " + vc.getURI())
|
||||||
|
if run:
|
||||||
|
vc.close()
|
||||||
|
- if (old_exitfunc):
|
||||||
|
- old_exitfunc()
|
||||||
|
|
||||||
|
- sys.exitfunc = exit
|
||||||
|
+ atexit.register(exit)
|
||||||
|
|
||||||
|
vc.registerCloseCallback(myConnectionCloseCallback, None)
|
||||||
|
|
||||||
|
--
|
||||||
|
2.38.1.windows.1
|
||||||
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
Summary: The libvirt virtualization API python3 binding
|
Summary: The libvirt virtualization API python3 binding
|
||||||
Name: libvirt-python
|
Name: libvirt-python
|
||||||
Version: 6.2.0
|
Version: 6.2.0
|
||||||
Release: 7
|
Release: 8
|
||||||
Source0: http://libvirt.org/sources/python/%{name}-%{version}.tar.gz
|
Source0: http://libvirt.org/sources/python/%{name}-%{version}.tar.gz
|
||||||
Patch0000: setup-use-pytest-instead-of-nose-to-run-the-test-sui.patch
|
Patch0000: setup-use-pytest-instead-of-nose-to-run-the-test-sui.patch
|
||||||
Patch0001: spec-use-pytest-instead-of-nose.patch
|
Patch0001: spec-use-pytest-instead-of-nose.patch
|
||||||
@ -15,6 +15,7 @@ Patch0006: Avoid-truncating-python-version-number-when-running-.patch
|
|||||||
Patch0007: Fix-the-invalid-operation-between-incompatible-types.patch
|
Patch0007: Fix-the-invalid-operation-between-incompatible-types.patch
|
||||||
Patch0008: Fix-string-formatting.patch
|
Patch0008: Fix-string-formatting.patch
|
||||||
Patch0009: Fix-BlockThreshold-Callback-argument-conversion-once.patch
|
Patch0009: Fix-BlockThreshold-Callback-argument-conversion-once.patch
|
||||||
|
Patch0010: examples-event-test-Use-atexit-for-Python-3.patch
|
||||||
Url: http://libvirt.org
|
Url: http://libvirt.org
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
BuildRequires: libvirt-devel == %{version}
|
BuildRequires: libvirt-devel == %{version}
|
||||||
@ -80,6 +81,9 @@ find examples -type f -exec chmod 0644 \{\} \;
|
|||||||
%{python3_sitearch}/*egg-info
|
%{python3_sitearch}/*egg-info
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jul 17 2023 shechenglong <shechenglong@xfusion.com> - 6.2.0-8
|
||||||
|
- examples: examples/event-test: Use atexit for Python 3
|
||||||
|
|
||||||
* Thu May 11 2023 ChenYanpan <chenyanpan@xfusion.com> - 6.2.0-7
|
* Thu May 11 2023 ChenYanpan <chenyanpan@xfusion.com> - 6.2.0-7
|
||||||
- add BuildRequires python3-libvirt to fix build failure
|
- add BuildRequires python3-libvirt to fix build failure
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user