File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,30 @@ on greenlets instead of threads.
19
19
20
20
Consideration on gevent's hub termination
21
21
-----------------------------------------
22
+ PyMongo uses threads to monitor your servers' topology and to handle
23
+ graceful reconnections.
24
+
22
25
When shutting down your application gracefully, your code be may waiting
23
26
for any remaining greenlet to terminate before exiting.
24
- Because monkey-patched threads are greenlets and PyMongo uses quite a lot
25
- of them, this may become a **blocking operation ** and may prevent your
26
- application to exit properly. You therefore must close (or dereference)
27
- any active MongoClient object before exiting !
27
+
28
+ This may become a **blocking operation ** because monkey-patched threads
29
+ are considered as greenlets and this could prevent your application
30
+ to exit properly. You therefore **must close or dereference ** any active
31
+ MongoClient object before exiting !
32
+
33
+ Code example, this function is called when your application is asked
34
+ to exit or gracefully reload itself by receiving a SIGHUP signal:
35
+
36
+ .. code-block :: python
37
+
38
+ import signal
39
+
40
+ def graceful_reload (signum , traceback ):
41
+ """ Explicitly close our connection
42
+ """
43
+ client.close()
44
+
45
+ signal.signal(signal.SIGHUP , graceful_reload)
28
46
29
47
**uWSGI ** applications using the ``gevent-wait-for-hub `` option are directly
30
48
affected by this behaviour.
You can’t perform that action at this time.
0 commit comments