Python Forum
Using multiprocessing to produce objects for i in range
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using multiprocessing to produce objects for i in range
#6
(Feb-02-2022, 01:41 PM)deanhystad Wrote: The difference between windows and unix is windows spawns a fresh process with all new global variables. This means each process has it's own global hotel[] and nobody adds items to the hotel[] in the parent process. To get around this you do not use global variables, but instead use local variables which are passed as arguments to the child processes. You can still use global variables in multiprocessing as long as they are not used to pass information back from the child processes. In your code origins[], ages[] and genders[] can be global variables. Every process will have their own variables, but they will all be the same.

In unix a process is forked. It starts out as an exact copy of the parent. This means the child processes have the same global variables as the parent processes.

Ok got it, more or less. I'm getting there. Excrutiatingly slowly, but I'm getting there.^^

So in the context of this code: can you edit the original so I can reverse engineer it, or is that too much trouble?

Also, does the manager make the code slower? And if it does, is there any point to multiprocessing in this case?

Or is there any other way to make a process return the list for the main process to pick up in some way? (In which case I would have to make separate functions for each process, I presume)
Reply


Messages In This Thread
RE: Using multiprocessing to produce objects for i in range - by lucasrohr - Feb-02-2022, 02:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Produce One file Per PurchaseOrder jland47 1 470 Jan-26-2024, 11:38 AM
Last Post: Larz60+
  matplotlib x axis range goes over the set range Pedroski55 5 3,466 Nov-21-2021, 08:40 AM
Last Post: paul18fr
Photo multiprocessing with objects? - help m3atwad 0 1,339 Nov-17-2020, 03:16 AM
Last Post: m3atwad
  Define a range, return all numbers of range that are NOT in csv data KiNeMs 18 7,527 Jan-24-2020, 06:19 AM
Last Post: KiNeMs
  Can the comments produce errors in python? newbieAuggie2019 9 4,697 Nov-26-2019, 12:19 AM
Last Post: micseydel
  Code works in IDLE, appears to work in CMD, but won't produce files in CMD/Windows ChrisPy33 3 3,368 Jun-12-2019, 05:56 AM
Last Post: ChrisPy33
  \t produce eight gap but tab only produce four gap liuzhiheng 3 2,562 Jun-09-2019, 07:05 PM
Last Post: Gribouillis
  Python Script to Produce Difference Between Files and Resolve DNS Query for the Outpu sultan 2 2,664 May-22-2019, 07:20 AM
Last Post: buran
  Convert file sizes: will this produce accurate results? RickyWilson 2 8,307 Dec-04-2017, 03:36 PM
Last Post: snippsat
  How can I produce a list of n times the same element? JoeB 6 3,924 Nov-27-2017, 10:40 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020