Python Forum
Wait for command within a process
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wait for command within a process
#2
Solution:
multiprocessing disables the stdin when it starts a process, therefore input() cannot be used.

https://stackoverflow.com/questions/4283...ing-a-line
Quote:The multiprocessing module doesn't let you read stdin. That makes sense generally because mixing stdin readers from multiple children is a risky business. In fact, digging into the implementation, multiprocessing/process.py explicitly sets stdin to devnull:

sys.stdin.close()
sys.stdin = open(os.devnull)


I've instead swapped to using a Thread to listen for the input:
from threading import Thread

# Main execution starts here
Thread(target=listenForCommand).start()
Reply


Messages In This Thread
Wait for command within a process - by bRitch022 - Jul-09-2020, 07:34 PM
RE: Wait for command within a process - by bRitch022 - Jul-15-2020, 07:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python multiprocessing Pool apply async wait for process to complete sunny9495 6 6,420 Apr-02-2022, 06:31 AM
Last Post: sunny9495
  Wait til a date and time KatManDEW 2 1,427 Mar-11-2022, 08:05 PM
Last Post: KatManDEW
  wait for the first of these events Skaperen 4 1,941 Mar-07-2022, 08:46 PM
Last Post: Gribouillis
  how to do a two-way wait Skaperen 2 1,267 Mar-04-2022, 02:31 AM
Last Post: Skaperen
  Run an app in a standalone terminal and wait until it's closed glestwid 2 2,518 Aug-30-2020, 08:14 AM
Last Post: glestwid
  python os.popen is not working for wait method elenaflorence87 0 2,004 Jul-22-2020, 12:56 PM
Last Post: elenaflorence87
  pydev debugger: process 3442 is connecting when I run a program with ALT+COMMAND+R Seneca260 1 2,648 Jan-06-2020, 06:57 PM
Last Post: micseydel
  How to sharing object between multiple process from main process using Pipe Subrata 1 3,667 Sep-03-2019, 09:49 PM
Last Post: woooee
  changing the process command line arguments in python Skaperen 3 3,015 Aug-19-2019, 02:40 PM
Last Post: wavic
  Subprocess.send_signal, wait until completion plinio 5 9,059 Jun-29-2018, 12:07 PM
Last Post: plinio

Forum Jump:

User Panel Messages

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