sharing a dict between child processes
Waqar Khan <[email protected]> Tue, 5 Nov 2019 22:19:56 -0800
| Newsgroups | gmane.comp.python.twisted |
|---|---|
| Message-ID | <CAJuJkHPSr-4E2p3XK9Ebf=sVN0zAXrFX6vdLwex6knPJojXVKw@mail.gmail.com> |
--===============6451941169196011398== Content-Type: multipart/alternative; boundary="00000000000052f65b0596a78a34" --00000000000052f65b0596a78a34 Content-Type: text/plain; charset="UTF-8" Hi, So, I am writing a twisted server. This server spawn multiple child processes using reactor spawnProcess that initializes a process protocol. Now, each of the childprocess receives some REST requests. Each process has a dict that acts as cache. Now, I want to share dict across processes. In general, python has SharedMemoryManager in multiprocessing module which would have helped. https://docs.python.org/3/library/multiprocessing.shared_memory.html#multiprocessing.managers.SharedMemoryManager.SharedMemory But since I am using twisted internal process implementation, how do I share this dict across the processes so that all the processes use this common cache? Thanks Waqar --00000000000052f65b0596a78a34 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi,<div>So, I am writing a twisted server. This server spa= wn multiple child processes using reactor spawnProcess that initializes a p= rocess protocol.</div><div><br>Now, each of the childprocess receives some = REST requests. Each process has a dict that acts as cache.=C2=A0</div><div>= Now, I want to share dict across processes.</div><div>In general, python ha= s SharedMemoryManager in multiprocessing module which would have helped.</d= iv><div><a href=3D"https://docs.python.org/3/library/multiprocessing.shared= _memory.html#multiprocessing.managers.SharedMemoryManager.SharedMemory">htt= ps://docs.python.org/3/library/multiprocessing.shared_memory.html#multiproc= essing.managers.SharedMemoryManager.SharedMemory</a><br></div><div>But sinc= e I am using twisted internal process implementation, how do I share this d= ict across the processes so that all the processes use this common cache?= =C2=A0</div><div>Thanks</div><div>Waqar</div></div> --00000000000052f65b0596a78a34-- --===============6451941169196011398== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVHdpc3RlZC1Q eXRob24gbWFpbGluZyBsaXN0ClR3aXN0ZWQtUHl0aG9uQHR3aXN0ZWRtYXRyaXguY29tCmh0dHBz Oi8vdHdpc3RlZG1hdHJpeC5jb20vY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3R3aXN0ZWQtcHl0 aG9uCg== --===============6451941169196011398==--