Python Forum
Launch another python command without waiting for a return.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Launch another python command without waiting for a return.
#5
The easy way would be to run it in a thread:
import threading

def do_something_and_move_on():
    pass

worker = threading.Thread(target=do_something_and_move_on)
worker.start()

# now do other things while it runs...

# then join the worker, to make sure it's done before the script ends
worker.join()
The more complicated answer would be to write your code using async/await, and let the asyncio library handle it for you. But that's harder to do if you already have code that you don't want to mess with.
Reply


Messages In This Thread
RE: Launch another python command without waiting for a return. - by nilamo - Jun-15-2020, 10:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on first Python launch garryp4 5 400 May-07-2024, 03:56 PM
Last Post: deanhystad
  Waiting for input from serial port, then move on KenHorse 3 1,263 Apr-17-2024, 07:21 AM
Last Post: DeaD_EyE
  pip stops waiting for python walker 6 1,155 Nov-28-2023, 06:55 PM
Last Post: walker
  Launch Python IDLE Shell from terminal Pavel_47 5 1,325 Feb-17-2023, 02:53 PM
Last Post: Pavel_47
  Waiting for heavy functions question philipbergwerf 14 3,511 Apr-29-2022, 07:31 PM
Last Post: philipbergwerf
  How to create waiting process? samuelbachorik 4 2,028 Sep-02-2021, 05:41 PM
Last Post: bowlofred
  Launch Windows Application OEMS1 0 2,192 Mar-26-2021, 07:42 PM
Last Post: OEMS1
Photo Python won`t launch error newbieee 0 1,813 Feb-02-2021, 11:51 PM
Last Post: newbieee
  Waiting and listening test 2 2,199 Nov-13-2020, 04:43 PM
Last Post: michael1789
  waiting for barcode scanner output, while main program continues to run lightframe109 3 4,734 Sep-03-2020, 02:19 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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