Python Forum
Updating variables in Multi-processing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating variables in Multi-processing
#11
I think that's because you're trying to access the value within the Manager, after the manager's been cleaned up from the with block. Try this:
if __name__ == '__main__':
    with multiprocessing.Manager() as manager:
        with multiprocessing.Pool(6) as p:
            error_value = manager.Value('i', 0)
            args = itertools.product(input_list, [error_value])
            results = p.map(get_data, args)
 
        for result in results:
              ...
        print("Total errors:", error_value.value)
Reply


Messages In This Thread
Updating variables in Multi-processing - by WiPi - Feb-09-2021, 01:11 PM
RE: Updating variables in Multi-processing - by nilamo - Feb-12-2021, 04:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Strategy on updating edits back to data table and object variables hammer 0 1,237 Dec-11-2021, 02:58 PM
Last Post: hammer
  Multi-processing to communicate with microcontrollers Khoily 1 2,565 Mar-01-2019, 08:57 PM
Last Post: DeaD_EyE
  Multi-processing - problem with running multiple *.py files at the same time Antonio 5 3,927 Sep-12-2018, 01:08 PM
Last Post: volcano63
  multi-processing dR_Garuby 1 2,708 Mar-24-2018, 05:59 PM
Last Post: woooee
  How does multi-processing in python increase the execution time? kadsank 0 2,365 Jan-15-2018, 01:15 PM
Last Post: kadsank
  Running Class methods in a loop and updating variables. ujjwalrathod007 3 6,505 Oct-05-2016, 07:11 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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