Skip to content

Commit

Permalink
Call gevent.monkey.patch_all immediately on import (#703)
Browse files Browse the repository at this point in the history
The api makes use of [gevent], a coroutine based networking
library which relies heavily on monkey patching the stdlib.

From the [gevent.monkey] docs:
> Warning Patching too late can lead to unreliable behaviour
> (for example, some modules may still use blocking sockets) or even errors.

This appears to have happened here. Thanks to @allwyn-pradip for
pointing me at the right file in PR
#690.

Resolves #686, #699, #644.

Blog on gevent: https://eng.lyft.com/what-the-heck-is-gevent-4e87db98a8
> In the case of gevent — monkey patching has to be the absolute first thing a process does

[gevent]: https://www.gevent.org/index.html
[gevent.monkey]: https://www.gevent.org/api/gevent.monkey.html
  • Loading branch information
bilbof authored Apr 11, 2022
1 parent 94b9897 commit 6a8a70b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/iris/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) LinkedIn Corporation. All rights reserved. Licensed under the BSD-2 Clause license.
# See LICENSE in the project root for license information.
from gevent import spawn, sleep, socket, Timeout
from gevent import spawn, sleep, socket, Timeout, monkey
monkey.patch_all() # NOQA

import msgpack
import time
Expand Down

0 comments on commit 6a8a70b

Please sign in to comment.