Python Forum
help with multiprocess concept
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with multiprocess concept
#3
thanks, but I'm not planning on using tkinter( i kind of hated using it) i'm sticking to just text based commands and a python script. also plotting may or may not be done, since it would have to depend on what is being called. Also the pyserial part has priority so i dont want anything to slow it down.

here is the solution found on stackoverflow from the user Carcigenicate

from operator import methodcaller

class Spawn:
    def __init__(self, _number, _max):
        self._number = _number
        self._max = _max
        # Don't call update here

    def request(self, x):
        print("{} was requested.".format(x))

    def update(self):
        while True:
            print("Spawned {} of {}".format(self._number, self._max))
            sleep(2)

if __name__ == '__main__':
    spawn = Spawn(1, 1)  # Create the object as normal

    p = multiprocessing.Process(target=methodcaller("update"), args=(spawn,)) # Run the loop in the process
    p.start()

    spawn.request(2)  # Now you can reference the "spawn" object to do whatever you like
Reply


Messages In This Thread
help with multiprocess concept - by kiyoshi7 - Aug-09-2019, 07:02 PM
RE: help with multiprocess concept - by woooee - Aug-09-2019, 08:54 PM
RE: help with multiprocess concept - by kiyoshi7 - Aug-10-2019, 08:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How we prune Alphabeta Tree Node Using BST concept Anldra12 4 2,439 May-18-2021, 09:17 AM
Last Post: Anldra12
  multiprocess hang when certain number is used in the program esphi 7 3,211 Nov-06-2020, 03:49 PM
Last Post: esphi
  prometheus in multiprocess code georgelza 4 3,998 Jan-21-2020, 05:13 PM
Last Post: georgelza
  Multiprocess not writing to file DreamingInsanity 4 7,970 Dec-07-2019, 03:10 PM
Last Post: DreamingInsanity
  Understanding the concept ( Modules , imports ) erfanakbari1 1 2,201 Nov-25-2019, 01:59 AM
Last Post: Larz60+
  Understand for range concept RavCOder 4 2,802 Oct-29-2019, 02:26 PM
Last Post: newbieAuggie2019
  Recursion concept Truman 8 8,716 Oct-06-2018, 07:48 AM
Last Post: Larz60+
  Concept of batch files Truman 2 2,842 Jul-23-2018, 09:02 PM
Last Post: Truman
  example of multiprocess piping Skaperen 4 6,052 Dec-02-2016, 12:55 PM
Last Post: Larz60+
  multiprocess passing multiple arguments double asterisk pic8690 1 5,293 Oct-23-2016, 08:51 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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