Re: How execute at least two python files at once when imported?
Cameron Simpson wrote: I was unsure as to how serialised this was: just the import data structures or the whole source-of-the-module. It's the whole source. I found that out the hard way once -- I had a thread that imported a module whose main code ran an event processing loop. It stopped any other threads from running, since the import statement never finished. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 08Nov2019 00:52, Greg Ewing wrote: Cameron Simpson wrote: Spencer's modules run unconditional stuff in addition to defining classes. That may cause trouble. It will -- because of the import lock, they won't run simultaneously in the same process. I was unsure as to how serialised this was: just the import data structures or the whole source-of-the-module. But I guess serialising the latter is essential anyway, now I think about it. Hence my separate post suggesting the OP move the "main task" into a function, runs the imports serailly (very cheap) and then kick off threads if that's what he wants. Thanks for the clarification. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
Cameron Simpson wrote: Spencer's modules run unconditional stuff in addition to defining classes. That may cause trouble. It will -- because of the import lock, they won't run simultaneously in the same process. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
OT language barrier, was: How execute at least two python files at once when imported?
Am 06.11.19 um 17:34 schrieb Igor Korot: On Wed, Nov 6, 2019 at 10:22 AM Spencer Du wrote: Sorry if I haven't stated my requirements clearly. I just wanted a way to import at least two python files in parallel and I wanted to know how this can be done or a reason why its bad as stated in another post. This is not a requirements. Let me rephrase my question - what problem are you trying to solve? Also, as I said before - I believe there is a language barrier. Find some python forum in your native language and ask your question there. Off topic, but how do you conclude that the OP is a non-native English speaker or has inferior command of the English language? He sounds very English to me, and the name and email address also do not indicate non-English origin to me? My impression was that there IS a language barrier for technical terms, but not with English per se - he used the word "import" incorrectly, when he meant "run", because he abused "import lala" to run a Python program. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 06Nov2019 08:16, Spencer Du wrote: Sorry if I haven't stated my requirements clearly. I just wanted a way to import at least two python files in parallel and I wanted to know how this can be done or a reason why its bad as stated in another post. Parallel imports can be fine. However, you want to avoid parallel code which works on shared data structures without the necessary synchronisation may be hazardous. Your modules look like this: import stuff ... define functions and classes inline code performing a kind of "main programme" That inline code gets run unconditionally, at import time. What would be better would be if your modules looked like this: import stuff ... define functions and classes def main(): inline code performing a kind of "main programme" Then your "real" main programme can go: import your_module1 import your_module2 start a thread running your_module1.main() start a thread running your_module2.main() which gets the imports done; they happen in series but just defining things (classes and functions) is very fast. Then dispatch some Threads to run your main functions from each module. If those main functions do not share data it will probably all just work. If they do share data then you may need to debug some synchronisation issues; it depends on the code itself. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 06Nov2019 18:15, Rhodri James wrote: On 06/11/2019 16:02, Spencer Du wrote: Why is importing modules in parallel bad? To put it as simply as I can: 1. The import mechanism is complicated, even the bits that are user-visible. Fiddling with it has a high chance of going wrong. 2. Multi-threading is less complicated than import, but still requires a lot of careful thought. For example you've asserted that the modules you want to import simultaneously, but you also need to consider the import mechanism itself. Put 1 and 2 together, and multi-threaded import sounds like a nightmare. The import machinery has an internal lock. Parallel import statements via threads is, of itself, a safe thing to do. But if the module does significant work on things outside itself (eg doing work beyond defining local classes, constants etc) that work needs to be thread safe. Provided the imported modules do only local work it should be safe. Spencer's modules run unconditional stuff in addition to defining classes. That may cause trouble. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 11/6/19 3:37 PM, Michael Torrie wrote: > On 11/6/19 9:16 AM, Spencer Du wrote: >> I just wanted a way to import at least two python files in parallel >> and I wanted to know how this can be done or a reason why its bad as >> stated in another post. > It's not "bad," but it's also not possible. Nor does it make sense. > That's why so many people are questioning what you are really trying to > accomplish. By definition a Python script is a sequence of statements > that are read and executed in sequence. You can't just run them all at > once, nor would it make sense to do so. > > If you want to run multiple python functions in parallel, there are > threads for that, multiprocessing, and also asynchronous scheduling. > > But no one can tell you what to do because none of us have any clue what > you are trying to accomplish. I would disagree that it isn't possible, depending on exactly what is wanted, I can think of several ways to do it. Simplest option is fork off a separate process and run the second script from that process, that would work if the two scripts don't need much communication between themselves, and you would need to manually add what ever communication was needed. A second option is to create a second thread, and do one if the imports in that thread, and one in the main thread. This is likely the closest to the stated goal, but likely, due to the GIL, slower than doing one after the other. -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
Igor Korot於 2019年11月7日星期四 UTC+8上午12時34分35秒寫道: > Hi, > > On Wed, Nov 6, 2019 at 10:22 AM Spencer Du wrote: > > > > Hi > > > > Sorry if I haven't stated my requirements clearly. > > > > I just wanted a way to import at least two python files in parallel and I > > wanted to know how this can be done or a reason why its bad as stated in > > another post. > > This is not a requirements. > > Let me rephrase my question - what problem are you trying to solve? > > Also, as I said before - I believe there is a language barrier. > > Find some python forum in your native language and ask your question there. > > Thank you. > > > > > Thanks > > Spencer > > -- > > https://mail.python.org/mailman/listinfo/python-list If the OP is a Chinese, from my experience, I doubt there is a chance he can express his problem clearly enough for us who want to help to understand. There is not only the language barrier, but the causes of China education system. Starts from the very beginning in primary school, students are not allowed to think independently and logically. So after growing up, they just lost the ability of expressing things in a logic way. --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 11/6/19 9:16 AM, Spencer Du wrote: > I just wanted a way to import at least two python files in parallel > and I wanted to know how this can be done or a reason why its bad as > stated in another post. It's not "bad," but it's also not possible. Nor does it make sense. That's why so many people are questioning what you are really trying to accomplish. By definition a Python script is a sequence of statements that are read and executed in sequence. You can't just run them all at once, nor would it make sense to do so. If you want to run multiple python functions in parallel, there are threads for that, multiprocessing, and also asynchronous scheduling. But no one can tell you what to do because none of us have any clue what you are trying to accomplish. -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On Wed, Nov 6, 2019 at 11:15 AM Rhodri James wrote: > On 06/11/2019 16:02, Spencer Du wrote: > > Why is importing modules in parallel bad? > > To put it as simply as I can: > > 1. The import mechanism is complicated, even the bits that are > user-visible. Fiddling with it has a high chance of going wrong. > > 2. Multi-threading is less complicated than import, but still requires a > lot of careful thought. For example you've asserted that the modules > you want to import simultaneously, but you also need to consider the > import mechanism itself. > > Put 1 and 2 together, and multi-threaded import sounds like a nightmare. > > -- > Rhodri James *-* Kynesim Ltd > -- > https://mail.python.org/mailman/listinfo/python-list > After spending way too much time chasing my tail down the rabbit hole on a similar project I decided that using the work of others was more productive. I've been using parallel with good success. Depends on how much you need to share with the different components. For details see https://www.gnu.org/software/parallel/ -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 06/11/2019 16:02, Spencer Du wrote: Why is importing modules in parallel bad? To put it as simply as I can: 1. The import mechanism is complicated, even the bits that are user-visible. Fiddling with it has a high chance of going wrong. 2. Multi-threading is less complicated than import, but still requires a lot of careful thought. For example you've asserted that the modules you want to import simultaneously, but you also need to consider the import mechanism itself. Put 1 and 2 together, and multi-threaded import sounds like a nightmare. -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
RE: How execute at least two python files at once when imported?
"Why is importing modules in parallel bad?" In general I'd say that "import foo" is supposed to be there because you want the classes, functions, variables etc. in foo to be available in your current program. A module should never run a whole bunch of time consuming stuff when it's imported. If you want to "run foo" rather than import it, then inside foo all the "running" code should be in a function which can be called later. If you want foo to be runnable directly you can then call that function from the classic if __name__ == "__main__": construct. That lets foo be importable, and lets you pick when you want the actual long stuff to run. #In foo.py def run_long_task(): long_stuff_here if __name__ == "__main__": #foo.py is being called directly, not imported run_long_task() So your main program should look something like: import foo #quick as just the definitions are processed foo.run_long_task() Or to "run" multiple other things at once it should look more like: import threading #multiprocessing, or other module here import foo #quick as just the definitions are processed import bar #quick as just the definitions are processed kick off foo.run_long_task() as its own thread/process/task/etc kick off bar.run_long_task() as its own thread/process/task/etc wait for them to finish and process results, or do stuff while they're running So again, "import" should never be used to "run" another file, just to "bring in the stuff from" another file. And any file designed to be imported should not run extra stuff during that import. -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
Hi, On Wed, Nov 6, 2019 at 10:22 AM Spencer Du wrote: > > Hi > > Sorry if I haven't stated my requirements clearly. > > I just wanted a way to import at least two python files in parallel and I > wanted to know how this can be done or a reason why its bad as stated in > another post. This is not a requirements. Let me rephrase my question - what problem are you trying to solve? Also, as I said before - I believe there is a language barrier. Find some python forum in your native language and ask your question there. Thank you. > > Thanks > Spencer > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On Wed, Nov 06, 2019 at 08:16:07AM -0800, Spencer Du wrote: > Sorry if I haven't stated my requirements clearly. > > I just wanted a way to import at least two python files in parallel and I > wanted to know how this can be done or a reason why its bad as stated in > another post. You stated your *desire* but not which (external) *requirement* this desire comes from. Long answer short: if you want exactly what you say then you'll have to run two separate machines and overcome the Heisenberg Principle with regards to syncronizing their runtime behaviour. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
Hi Sorry if I haven't stated my requirements clearly. I just wanted a way to import at least two python files in parallel and I wanted to know how this can be done or a reason why its bad as stated in another post. Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
Hi, I think what you are trying is a "chicken-egg" problem. You should clearly state you requirements in order for us to help you. If you have a problem with English I'm sure there is some python-related list/forum in your native language. Just google it. Thank you. On Wed, Nov 6, 2019 at 10:07 AM Spencer Du wrote: > > Why is importing modules in parallel bad? > > Thanks > Spencer > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
Why is importing modules in parallel bad? Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 5/11/19 19:33, Spencer Du wrote: > Hi > > I want to execute at least two python files at once when imported but I dont > know how to do this. Currently I can only import each file one after another > but what i want is each file to be imported at the same time. Can you help me > write the code for this? embedded.py is the main file to execute. Your question is confusing. In the header and in your first sentence you talk about executing. But later you talk about importing. -- Antoon -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 06/11/2019 11:42, Rhodri James wrote: On 06/11/2019 09:51, Spencer Du wrote: On Tuesday, 5 November 2019 19:44:46 UTC+1, Rhodri James wrote: On 05/11/2019 18:33, Spencer Du wrote: I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. That is a very odd requirement. Why would you want to do this? What exactly does "at the same time" mean here? These are modules/files which are independent of each other and have no dependencies with one another. Because of this I want to run modules all at once. "All at once" still isn't a very meaningful phrase. If you want to import modules in parallel, don't. Not only is it hard work to do, it will come back and bite you. Also posting exactly the same answer word for word four different times isn't a very helpful thing to do. -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 06/11/2019 09:51, Spencer Du wrote: On Tuesday, 5 November 2019 19:44:46 UTC+1, Rhodri James wrote: On 05/11/2019 18:33, Spencer Du wrote: I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. That is a very odd requirement. Why would you want to do this? What exactly does "at the same time" mean here? These are modules/files which are independent of each other and have no dependencies with one another. Because of this I want to run modules all at once. "All at once" still isn't a very meaningful phrase. If you want to import modules in parallel, don't. Not only is it hard work to do, it will come back and bite you. -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On Tuesday, 5 November 2019 19:44:46 UTC+1, Rhodri James wrote: > On 05/11/2019 18:33, Spencer Du wrote: > > I want to execute at least two python files at once when imported but > > I dont know how to do this. Currently I can only import each file one > > after another but what i want is each file to be imported at the same > > time. > > That is a very odd requirement. Why would you want to do this? What > exactly does "at the same time" mean here? > > -- > Rhodri James *-* Kynesim Ltd These are modules/files which are independent of each other and have no dependencies with one another. Because of this I want to run modules all at once. -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On Tuesday, 5 November 2019 19:41:59 UTC+1, Bob Gailer wrote: > On Nov 5, 2019 1:35 PM, "Spencer Du" wrote: > > > > Hi > > > > I want to execute at least two python files at once when imported but I > dont know how to do this. Currently I can only import each file one after > another but what i want is each file to be imported at the same time. Can > you help me write the code for this? > > Please explain what you mean by "imported at the same time". As far as I > know that is physically impossible. These are modules/files which are independent of each other and have no dependencies with one another. Because of this I want to run modules all at once. -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On Tuesday, 5 November 2019 21:05:02 UTC+1, Terry Reedy wrote: > On 11/5/2019 1:33 PM, Spencer Du wrote: > > > I want to execute at least two python files at once when imported but I > > dont know how to do this. Currently I can only import each file one after > > another but what i want is each file to be imported at the same time. Can > > you help me write the code for this? embedded.py is the main file to > > execute. > > [snip about 150 lines of example code] > > We don't understand what you mean other than something impossible. Your > example code iswa ytoo long. It should be the minimum > needed to illustrate the idea. > > -- > Terry Jan Reedy These are modules/files which are independent of each other and have no dependencies with one another. Because of this I want to run modules all at once. -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On Tuesday, 5 November 2019 19:37:32 UTC+1, Karsten Hilbert wrote: > > I want to execute at least two python files at once when imported but I > > dont know how to do this. > > Currently I can only import each file one after another but what i want is > > each file to be imported > > at the same time. > > Can you explain why that seems necessary ? > > Karsten These are modules/files which are independent of each other and have no dependencies with one another. Because of this I want to run modules all at once. -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On Wednesday, 6 November 2019 09:05:42 UTC+1, Christian Gollwitzer wrote: > Am 06.11.19 um 03:59 schrieb Dennis Lee Bieber: > > On Tue, 5 Nov 2019 10:33:20 -0800 (PST), Spencer Du > > declaimed the following: > > > >> Hi > >> > >> I want to execute at least two python files at once when imported but I > >> dont know how to do this. Currently I can only import each file one after > >> another but what i want is each file to be imported at the same time. Can > >> you help me write the code for this? embedded.py is the main file to > >> execute. > > > > > > Short answer: you don't. > > > > When you import a module, the code for that module is parsed and > > anything that is module level executable statement is done (note: "def" is > > an executable statement -- it creates a function object contained the > > parsed body and binds it to the provided name). When the parser gets to the > > end of the module, it returns to the parent level and the next statement is > > executed. > > > > Unless you use 1) threads; 2) subprocesses; or 3) multiprocess a Python > > program only has one line of control, and that control is sequential. > > Since some of these example programs use asyncio, there is a 4th method. > You convert all the programs to use asyncio, remove the event loop from > these programs, i.e. remove the > > asyncio.get_event_loop().run_until_complete(main()) > > from the individual programs, and then you run a single event loop in > your main program. Something like > >loop = asyncio.get_event_loop() >loop.run_until_complete(asyncio.gather(laserembeded.main(), > camerasembedded.main())) > > > Christian Ok I am interested in knowing how i can do it via either 1) threads; 2) subprocesses; or 3) multiprocess; depending on what you think is the best method. Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
Am 06.11.19 um 03:59 schrieb Dennis Lee Bieber: On Tue, 5 Nov 2019 10:33:20 -0800 (PST), Spencer Du declaimed the following: Hi I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. Can you help me write the code for this? embedded.py is the main file to execute. Short answer: you don't. When you import a module, the code for that module is parsed and anything that is module level executable statement is done (note: "def" is an executable statement -- it creates a function object contained the parsed body and binds it to the provided name). When the parser gets to the end of the module, it returns to the parent level and the next statement is executed. Unless you use 1) threads; 2) subprocesses; or 3) multiprocess a Python program only has one line of control, and that control is sequential. Since some of these example programs use asyncio, there is a 4th method. You convert all the programs to use asyncio, remove the event loop from these programs, i.e. remove the asyncio.get_event_loop().run_until_complete(main()) from the individual programs, and then you run a single event loop in your main program. Something like loop = asyncio.get_event_loop() loop.run_until_complete(asyncio.gather(laserembeded.main(), camerasembedded.main())) Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 11/5/2019 1:33 PM, Spencer Du wrote: I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. Can you help me write the code for this? embedded.py is the main file to execute. [snip about 150 lines of example code] We don't understand what you mean other than something impossible. Your example code iswa ytoo long. It should be the minimum needed to illustrate the idea. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On 05/11/2019 18:33, Spencer Du wrote: I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. That is a very odd requirement. Why would you want to do this? What exactly does "at the same time" mean here? -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On Nov 5, 2019 1:35 PM, "Spencer Du" wrote: > > Hi > > I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. Can you help me write the code for this? Please explain what you mean by "imported at the same time". As far as I know that is physically impossible. -- https://mail.python.org/mailman/listinfo/python-list
Aw: How execute at least two python files at once when imported?
> I want to execute at least two python files at once when imported but I dont > know how to do this. > Currently I can only import each file one after another but what i want is > each file to be imported > at the same time. Can you explain why that seems necessary ? Karsten -- https://mail.python.org/mailman/listinfo/python-list
How execute at least two python files at once when imported?
Hi I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. Can you help me write the code for this? embedded.py is the main file to execute. embedded.py import paho.mqtt.client as mqtt from mqtt2 import * import os import time import json import configparser from threading import Thread def start(): try: os.remove("list_of_device(s)_currently_active.txt") os.remove("laser.ini") print("Awaiting device(s) to be activated") except: print("Awaiting device(s) to be activated") start() devices = list(map(str,input("Device(s) to be activated: ").split(","))) client = embedded() client.run() client.loop_start() print("Connected to broker") time.sleep(1) print("Subscribing to topic", "microscope/light_sheet_microscope/UI") client.subscribe("microscope/light_sheet_microscope/UI") print("Publishing message to topic", "microscope/light_sheet_microscope/UI") client.publish("microscope/light_sheet_microscope/UI", json.dumps({"type": "system", "payload":{"name": devices, "cmd": "activating device(s)"}}, indent=2)) time.sleep(1) def active_devices(): for item in devices: device = (item + "Embedded") deviceImport = __import__(device) with open("list_of_device(s)_currently_active.txt", "a+") as myfile: for item in devices: myfile.write(item + "\n") active_devices() def readFile(fname): print("List of device(s) currently active:") try: with open(fname, "r") as f: for item in f: print(item.rstrip("\n")) except: print("No device(s) added yet") readFile("list_of_device(s)_currently_active.txt") # print("Connected to broker") # time.sleep(1) # client.subscribe("microscope/light_sheet_microscope/UI/laser/#") # if os.path.exists: # parser = configparser.ConfigParser() # parser.read("laser.ini") # try: # subscriptions = dict(parser.items("Subscriptions")) # print("Subscribing to topics", subscriptions) # client.subscribe(subscriptions) # except: # pass # else: # pass client.loop_forever() laserEmbedded.py import random import asyncio from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference from mqtt2 import * class Laser(Actor): async def handle_message(self, message: Message): print("Laser") await asyncio.sleep(2) print("Unitialised") await asyncio.sleep(2) print("Initialising") await asyncio.sleep(2) print("Initialised") await asyncio.sleep(2) print("Configuring") await asyncio.sleep(2) print("Configured") await asyncio.sleep(2) await message.sender.tell(DataMessage(data="Hello World Im a laser!" + "\n", sender=self)) async def main(): # Let's create an instance of a Greeter actor and start it. async with Laser() as laser: # Then we'll just send it an empty message and wait for a response reply : DataMessage = await ask(laser, Message()) print(reply.data) asyncio.get_event_loop().run_until_complete(main()) def subscribe(): client = embedded() client.run() client.loop_start() client.subscribe("microscope/light_sheet_microscope/UI/laser/#") subscribe() camerasEmbedded.py import random import asyncio from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference class Cameras(Actor): async def handle_message(self, message: Message): print("Cameras") await asyncio.sleep(2) print("Unitialised") await asyncio.sleep(2) print("Initialising") await asyncio.sleep(2) print("Initialised") await asyncio.sleep(2) print("Configuring") await asyncio.sleep(2) print("Configured") await asyncio.sleep(2) await message.sender.tell(DataMessage(data="Hello World Im a camera!" + "\n", sender=self)) async def main(): # Let's create an instance of a Greeter actor and start it. async with Cameras() as cameras: # Then we'll just send it an empty message and wait for a response reply : DataMessage = await ask(cameras, Message()) print(reply.data) asyncio.get_event_loop().run_until_complete(main()) filterwheelEmbedded.py import random import asyncio from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference class FW(Actor): async def handle_message(self, message: Message): print("Filter wheel") await asyncio.sleep(2) print("Unitialised") await asyncio.sleep(2) print("Initialising") await asyncio.sleep(2) print("Initialised") await asyncio.sleep(2) print("Configuring") await asyncio.sleep(2) print("Configured") await asyncio.sleep(2)