1

I'm trying to implement multiprocessing to decrease the startup time of my flask service. I'm able to do that. In each Process, new property gets added to the application context. But the main application context is not getting updated as each process starts its own context. Is there a way to maintain the application context across different process?

1 Answers1

1

Python multiprocessing can share state between processes, but this is somewhat limited. It does not support arbitrary objects.

You can also use a multiprocessing.Queue to send objects from a Process to the parent. However, these objects need to be pickleable, and there are some restrictions on that.

Roland Smith
  • 42,427
  • 3
  • 64
  • 94
  • I have tried using `multiprocessing.Queue` but it doesn't work. Yeah they need to be _pickleable_. I guess flask's `application context` is not shareable among processes. – jiteshfulwariya Aug 28 '19 at 19:36