<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/python-packages/eventlet.git/eventlet/patcher.py, branch 485-https-noverify-env</title>
<subtitle>github.com: eventlet/eventlet.git
</subtitle>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/'/>
<entry>
<title>Clean up threading book-keeping at fork when monkey-patched</title>
<updated>2020-08-29T03:58:07+00:00</updated>
<author>
<name>Tim Burke</name>
<email>tim.burke@gmail.com</email>
</author>
<published>2020-05-07T23:00:30+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=115103d5608cbe8f15df10e27eba1644f5364e95'/>
<id>115103d5608cbe8f15df10e27eba1644f5364e95</id>
<content type='text'>
Previously, if we patched threading then forked (or, in some cases, used
the subprocess module), Python would log an ignored exception like

   Exception ignored in: &lt;function _after_fork at 0x7f16493489d8&gt;
   Traceback (most recent call last):
     File "/usr/lib/python3.7/threading.py", line 1335, in _after_fork
       assert len(_active) == 1
   AssertionError:

This comes down to threading in Python 3.7+ having an import side-effect
of registering an at-fork callback. When we re-import threading to patch
it, the old (but still registered) callback still points to the old
thread-tracking dict, rather than the new dict that's actually doing the
tracking.

Now, register our own at_fork hook that will fix up the dict reference
before threading's _at_fork runs and put it back afterwards.

Closes #592
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, if we patched threading then forked (or, in some cases, used
the subprocess module), Python would log an ignored exception like

   Exception ignored in: &lt;function _after_fork at 0x7f16493489d8&gt;
   Traceback (most recent call last):
     File "/usr/lib/python3.7/threading.py", line 1335, in _after_fork
       assert len(_active) == 1
   AssertionError:

This comes down to threading in Python 3.7+ having an import side-effect
of registering an at-fork callback. When we re-import threading to patch
it, the old (but still registered) callback still points to the old
thread-tracking dict, rather than the new dict that's actually doing the
tracking.

Now, register our own at_fork hook that will fix up the dict reference
before threading's _at_fork runs and put it back afterwards.

Closes #592
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix #508: Py37 Deadlock ThreadPoolExecutor (#598)</title>
<updated>2020-05-15T18:14:22+00:00</updated>
<author>
<name>Gorka Eguileor</name>
<email>gorka@eguileor.com</email>
</author>
<published>2020-05-15T18:14:22+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=99e0c110a47bef59be2b0139309544d083dc5a06'/>
<id>99e0c110a47bef59be2b0139309544d083dc5a06</id>
<content type='text'>
Python 3.7 and later implement queue.SimpleQueue in C, causing a
deadlock when using ThreadPoolExecutor with eventlet.

To avoid this deadlock we now replace the C implementation with the
Python implementation on monkey_patch for Python versions 3.7 and
higher.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Python 3.7 and later implement queue.SimpleQueue in C, causing a
deadlock when using ThreadPoolExecutor with eventlet.

To avoid this deadlock we now replace the C implementation with the
Python implementation on monkey_patch for Python versions 3.7 and
higher.</pre>
</div>
</content>
</entry>
<entry>
<title>[bug] reimport submodule as well in patcher.inject (#540)</title>
<updated>2019-01-23T11:10:23+00:00</updated>
<author>
<name>Junyi</name>
<email>xmaswillyou@gmail.com</email>
</author>
<published>2019-01-23T11:10:23+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=05d613d8ed123b87f64f8d1987968c5bf825b07a'/>
<id>05d613d8ed123b87f64f8d1987968c5bf825b07a</id>
<content type='text'>
* [bug] reimport submodule as well in patcher.inject

* [dev] add unit-test

* [dev] move unit test to isolated tests

* improve unit test
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* [bug] reimport submodule as well in patcher.inject

* [dev] add unit-test

* [dev] move unit test to isolated tests

* improve unit test
</pre>
</div>
</content>
</entry>
<entry>
<title>external dependencies for six, monotonic, dnspython</title>
<updated>2018-05-10T17:33:32+00:00</updated>
<author>
<name>nat-goodspeed</name>
<email>nat@lindenlab.com</email>
</author>
<published>2018-05-10T17:33:32+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=53b63c66f0d9a7d6ba9182a207529ebd949e95f3'/>
<id>53b63c66f0d9a7d6ba9182a207529ebd949e95f3</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>patcher: workaround for monotonic "no suitable implementation"</title>
<updated>2017-08-26T07:58:58+00:00</updated>
<author>
<name>Geoffrey Thomas</name>
<email>geofft@twosigma.com</email>
</author>
<published>2017-08-25T19:09:06+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=b756447bab51046dfc6f1e0e299cc997ab343701'/>
<id>b756447bab51046dfc6f1e0e299cc997ab343701</id>
<content type='text'>
In some cases -- notably with Python 2.7.13 and the default hub -- the
process of importing the hub involves calling code in a module we
monkey-patch. This leads to recursive imports: the first eventlet
function will call get_hub(), which will try to import the hub, which
will call a monkey-patched module, which will call get_hub() and try to
import the hub again.

To avoid this, make sure the hub is fully imported before
monkey-patching anything.

https://github.com/eventlet/eventlet/issues/401
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In some cases -- notably with Python 2.7.13 and the default hub -- the
process of importing the hub involves calling code in a module we
monkey-patch. This leads to recursive imports: the first eventlet
function will call get_hub(), which will try to import the hub, which
will call a monkey-patched module, which will call get_hub() and try to
import the hub again.

To avoid this, make sure the hub is fully imported before
monkey-patching anything.

https://github.com/eventlet/eventlet/issues/401
</pre>
</div>
</content>
</entry>
<entry>
<title>patcher: set locked RLocks' owner only when patching existing locks</title>
<updated>2017-05-11T02:32:43+00:00</updated>
<author>
<name>Quan Tian</name>
<email>qtian@vmware.com</email>
</author>
<published>2017-05-09T07:34:33+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=f72cc96a70f9e9d23fc6e00d994263829b672be0'/>
<id>f72cc96a70f9e9d23fc6e00d994263829b672be0</id>
<content type='text'>
For Python 2, patching existing locks replaces RLock._RLock__owner with current
thread ID no matter the old lock is locked or not and thus an unlocked RLock
would have a non None owner (e.g. &lt;_RLock owner=140106584489808 count=0&gt;).
Then if we acquire the RLock in the same thread, the method RLock.acquire would
not invoke the _RLock__block.acquire() since it treats this is a recursive
acquire by checking current thread ID. And then the following RLock.release
would invoke the _RLock__block.release method resulting in the counter of
Semaphore being improved to 2.

There should be only two states being expected for RLock:
1. owner != None and count &gt; 0
2. owner == None and count == 0

This patch fixs it by only setting locked RLocks' owner during patching.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For Python 2, patching existing locks replaces RLock._RLock__owner with current
thread ID no matter the old lock is locked or not and thus an unlocked RLock
would have a non None owner (e.g. &lt;_RLock owner=140106584489808 count=0&gt;).
Then if we acquire the RLock in the same thread, the method RLock.acquire would
not invoke the _RLock__block.acquire() since it treats this is a recursive
acquire by checking current thread ID. And then the following RLock.release
would invoke the _RLock__block.release method resulting in the counter of
Semaphore being improved to 2.

There should be only two states being expected for RLock:
1. owner != None and count &gt; 0
2. owner == None and count == 0

This patch fixs it by only setting locked RLocks' owner during patching.
</pre>
</div>
</content>
</entry>
<entry>
<title>patcher: green existing locks fail (Python3)</title>
<updated>2016-11-30T22:34:14+00:00</updated>
<author>
<name>Whitney Young</name>
<email>wbyoung@users.noreply.github.com</email>
</author>
<published>2016-11-30T22:34:14+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=32e2c335fbbcf854c856784c6b07357eb46a8d37'/>
<id>32e2c335fbbcf854c856784c6b07357eb46a8d37</id>
<content type='text'>
Introduced in #309, this enumeration should be over the items of the
dict in order to work correctly.

https://github.com/eventlet/eventlet/pull/356
https://github.com/eventlet/eventlet/pull/309</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Introduced in #309, this enumeration should be over the items of the
dict in order to work correctly.

https://github.com/eventlet/eventlet/pull/356
https://github.com/eventlet/eventlet/pull/309</pre>
</div>
</content>
</entry>
<entry>
<title>Remove select.poll and improve subprocess</title>
<updated>2016-05-20T08:23:36+00:00</updated>
<author>
<name>Jakub Stasiak</name>
<email>jakub@stasiak.at</email>
</author>
<published>2016-05-20T08:23:36+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=614a20462aebfe85a54ce35a7daaf1a7dbde44a7'/>
<id>614a20462aebfe85a54ce35a7daaf1a7dbde44a7</id>
<content type='text'>
green select: Delete unpatched poll once again

https://github.com/eventlet/eventlet/pull/317

Previously attempted in f63165c, had to be reverted in 8ea9df6 because
subprocess was failing after monkey patching.

Turns out we haven't been monkey patching the subprocess module at all,
this patch adds that in order for the tests to pass.

This part is changed because otherwise Popen class instantiation would
cause an infinite loop when monkey patching is applied:

    -subprocess_orig = __import__("subprocess")
    +subprocess_orig = patcher.original("subprocess")

This patch is contributed by Smarkets Limited.

* green subprocess: Provide green check_output

This patch is contributed by Smarkets Limited.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
green select: Delete unpatched poll once again

https://github.com/eventlet/eventlet/pull/317

Previously attempted in f63165c, had to be reverted in 8ea9df6 because
subprocess was failing after monkey patching.

Turns out we haven't been monkey patching the subprocess module at all,
this patch adds that in order for the tests to pass.

This part is changed because otherwise Popen class instantiation would
cause an infinite loop when monkey patching is applied:

    -subprocess_orig = __import__("subprocess")
    +subprocess_orig = patcher.original("subprocess")

This patch is contributed by Smarkets Limited.

* green subprocess: Provide green check_output

This patch is contributed by Smarkets Limited.
</pre>
</div>
</content>
</entry>
<entry>
<title>patcher: patch existing threading locks; Thanks to Alexis Lee</title>
<updated>2016-04-18T20:07:00+00:00</updated>
<author>
<name>Alexis Lee</name>
<email>github@lxsli.co.uk</email>
</author>
<published>2016-04-18T20:07:00+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=bbeaa2e3a0b6da26af08f5e6734767e04c187c5b'/>
<id>bbeaa2e3a0b6da26af08f5e6734767e04c187c5b</id>
<content type='text'>
In projects which dynamically determine whether to activate eventlet,
it can be hard not to import a low level module like logging before
eventlet. When logging is imported it initialises a threading.RLock
which it uses to protect the logging configuration. If two
greenthreads attempt to claim this lock, the second one will block the
/native/ thread not just itself. As green systems usually only have
one native thread, this will freeze the whole system.

Search the GC for unsafe RLocks and replace their internal Lock with a
safe one while monkey-patching.

The tests pass, but were they to fail, the test process would never
return. To deal with this, I've added a test dependency on
subprocess32 which is a backport of the stdlib subprocess module from
Python3. This offers a timeout option on Popen#communicate, which I've
arbitrarily set at 30 seconds.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In projects which dynamically determine whether to activate eventlet,
it can be hard not to import a low level module like logging before
eventlet. When logging is imported it initialises a threading.RLock
which it uses to protect the logging configuration. If two
greenthreads attempt to claim this lock, the second one will block the
/native/ thread not just itself. As green systems usually only have
one native thread, this will freeze the whole system.

Search the GC for unsafe RLocks and replace their internal Lock with a
safe one while monkey-patching.

The tests pass, but were they to fail, the test process would never
return. To deal with this, I've added a test dependency on
subprocess32 which is a backport of the stdlib subprocess module from
Python3. This offers a timeout option on Popen#communicate, which I've
arbitrarily set at 30 seconds.</pre>
</div>
</content>
</entry>
<entry>
<title>patcher: Eliminate some redundancy</title>
<updated>2016-01-12T19:57:05+00:00</updated>
<author>
<name>Jakub Stasiak</name>
<email>jakub@stasiak.at</email>
</author>
<published>2016-01-12T19:57:05+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/python-packages/eventlet.git/commit/?id=f57d969fc3cb1a88f87660481f677447d9f1e1cd'/>
<id>f57d969fc3cb1a88f87660481f677447d9f1e1cd</id>
<content type='text'>
All those code blocks do the same thing so I decided to extract the
logic into a one place.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
All those code blocks do the same thing so I decided to extract the
logic into a one place.
</pre>
</div>
</content>
</entry>
</feed>
