D
D
Dmitry2018-04-30 12:45:36
Python
Dmitry, 2018-04-30 12:45:36

How to make code compatible with gevent?

Hey! Happy upcoming Holidays to all, especially those who have this holiday, mostly Labor :)
I have some misunderstandings with the transition to gevent. I am writing in Django and everything seems to be more or less clear there: I connected all the necessary modules to work with gevent, pro-mock-patched everything as it should be, made a connection pool with the base that supports gevent. Everything works, parallelized.
Now directly in the business logic of the application. What should I do? I have views that take a long time to parse some documents in response to a request. For two or three seconds. Sometimes even 10 seconds. Processing uses third-party libraries.
If I understand the essence of gevent correctly, then parallelism works exactly until a code is encountered that completely blocks the execution of greenlets. Those. if any external library encounters long calculations, then my application will stop accepting external connections until the gevent-incompatible code ends, right? Or will this greenlet simply be blocked with a call to this library, but other connections will still be accepted?
If my first guess is correct, then the next question is: what is the way out of this impasse? Rewrite third party libraries to support gevent?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question