Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #5627

[Python-de] multiprocessing mit shared mem not working

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From "Joachim Sasse" <sasse@simply-running-systems.com>
Newsgroups de.comp.lang.python
Subject [Python-de] multiprocessing mit shared mem not working
Date Sun, 08 Mar 2020 14:41:33 +0000
Lines 36
Message-ID <mailman.145.1583680029.9235.python-de@python.org> (permalink)
References <ema0c1a31b-14cd-4e7d-82e5-77b1bf28e581@z97-extreme9>
Reply-To "Joachim Sasse" <sasse@simply-running-systems.com>
Mime-Version 1.0
Content-Type text/plain; format=flowed; charset=utf-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de ThixcWXBE6OibB2Gd/M2RwRtkGSA7hSPgKMMIZeok2NA==
Return-Path <sasse@simply-running-systems.com>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; t=1583678838; s=strato-dkim-0002; d=simply-running-systems.com; h=Reply-To:Message-Id:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH: From:Subject:Sender; bh=hx61NoH9E92W+3/Qu4+0Ox0TiPkCRhQITPHfUF/vH+I=; b=c1Xv34RJGzdrKCH1eSzp5kV0EQZbReWetGkW/BWY5D7HZw6dfTVYtEqykHbe2xE9AX OiZ1EKEf1z7pW0LZxPsaYYFNMJrJfMa35ci8bGHha6RrbTFoE5EvszBgTAP0X2GJr0N4 WdUEN6L6b+piaIo6UrlGdq9JbLC+5cMrqK2x4aQDR3idRG3L/AqWsE2FD1KlFw0RPQVa Tl93wxwdZt8sQrcg3Bmj90iGg6K5cRt0feF7989fRTRX5l9qV5LppjopuEIvdCZutIoE s70ivb2gKj0MUw7Affcu1fo+4r6vqUhPeSLAjADmYklrYE+G2kj+IeTvIhyuTgqr47C5 TRbg==
X-RZG-AUTH ":P20XZkWIaPZMb6QucISpGdeo9F9tkBkPr4+WqvdvFhz5Z1edESKhlyS4BfrRsSbK2yHwANKCs8ODsQWbO0Gr1FJmkjs="
X-RZG-CLASS-ID mo00
User-Agent eM_Client/7.2.38682.0
X-Mailman-Approved-At Sun, 08 Mar 2020 11:07:09 -0400
X-Content-Filtered-By Mailman/MimeDel 2.1.30rc1
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.30rc1
Precedence list
List-Id Die Deutsche Python Mailingliste <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <ema0c1a31b-14cd-4e7d-82e5-77b1bf28e581@z97-extreme9>
Xref csiph.com de.comp.lang.python:5627

Show key headers only | View raw


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 | NextNext in thread | Find similar


Thread

[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