-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
threading related deprecation fixes for python 3.10 #2028
Conversation
f6ebc82
to
20c5484
Compare
@@ -80,7 +81,7 @@ def reverse_forward_tunnel(server_port, remote_host, remote_port, transport): | |||
thr = threading.Thread( | |||
target=handler, args=(chan, remote_host, remote_port) | |||
) | |||
thr.setDaemon(True) | |||
set_daemon(thr, True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use simply thr.daemon = True
with Python 2.7 and 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops I got the description wrong, this is for py2.6 support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The daemon
attribute is available since Python 2.6 and works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait only 3.3 needs the old method names? It seems the new way is supported from 2.6+? #1870 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've confirmed with Python 2.6 and just confirmed now.
$ python2.6
Python 2.6.9 (default, Jul 29 2017, 12:47:14)
[GCC 5.4.0 20160609] on linux4
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> import time
>>> t = threading.Thread(target=lambda: time.sleep(1000))
>>> t.daemon = True
>>> t.start()
>>> t.is_alive()
True
>>> #=> it is able to exit without no wait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait only 3.3 needs the old method names? It seems the new way is supported from 2.6+? #1870 (comment)
I recommend checking documentation. The daemon
and notify_all
are available on Python 3.0.
@@ -101,7 +101,7 @@ def feed(self, data): | |||
if self._event is not None: | |||
self._event.set() | |||
self._buffer_frombytes(b(data)) | |||
self._cv.notifyAll() | |||
notify_all(self._cv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use simply self._cv.notify_all()
with Python 2.7 and 3.
This property and method have been supported since 2.6 |
fixes #1838
remake of #1870 with py2.6 support