Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5627
| From | "Joachim Sasse" <sasse@simply-running-systems.com> |
|---|---|
| Newsgroups | de.comp.lang.python |
| Subject | [Python-de] multiprocessing mit shared mem not working |
| Date | 2020-03-08 14:41 +0000 |
| Message-ID | <mailman.145.1583680029.9235.python-de@python.org> (permalink) |
| References | <ema0c1a31b-14cd-4e7d-82e5-77b1bf28e581@z97-extreme9> |
Hello ,
it is not working - only a little test - what is wrong ?
# Python -- v3.8 - windows 10
from multiprocessing import Process, Queue, managers
import time
def with_shared_memory():
with managers.SharedMemoryManager() as smm:
sl = smm.ShareableList(range(2000))
# Divide the work among two processes, storing partial results
in sl
p1 = Process(target=do_work, args=(sl, 0, 1000))
print (p1)
p2 = Process(target=do_work, args=(sl, 1000, 2000))
p1.start()
p2.start() # A multiprocessing.Pool might be more efficient
p1.join()
p2.join() # Wait for all work to complete in both processes
total_result = sum(sl) # Consolidate the partial results now
in sl
print (total_result)
def do_work(data,von,bis):
print (von,bis)
for i in range(von,bis):
data.append(i)
with_shared_memory()
Back to de.comp.lang.python | Previous | Next — Next in thread | Find similar
[Python-de] multiprocessing mit shared mem not working "Joachim Sasse" <sasse@simply-running-systems.com> - 2020-03-08 14:41 +0000 Re: [Python-de] multiprocessing mit shared mem not working Hermann Riemann <nospam.ng@hermann-riemann.de> - 2020-03-08 16:50 +0100
csiph-web