How to handle pexpect.expect with multiprocessing?How should I log while using multiprocessing in Python?Keyboard Interrupts with python's multiprocessing PoolCan't pickle <type 'instancemethod'> when using multiprocessing Pool.map()Multiprocessing vs Threading PythonMultiprocessing: How to use Pool.map on a function defined in a class?Python multiprocessing pool.map for multiple argumentsDjango multiprocessing and database connectionsMultiprocessing - Pipe vs QueuePython multiprocessing PicklingError: Can't pickle <type 'function'>Django and multiprocessing AttributeError: Can't pickle local object
Basic power tool set for Home repair and simple projects
What is this plant I saw for sale at a Romanian farmer's market?
Why do you need to heat the pan before heating the olive oil?
What is the precise meaning of "подсел на мак"?
Can you cover a cube with copies of this shape?
Lead the way to this Literary Knight to its final “DESTINATION”
How did the European Union reach the figure of 3% as a maximum allowed deficit?
...and then she held the gun
First occurrence in the Sixers sequence
SQL Server has encountered occurences of I/O requests taking longer than 15 seconds
Why is Skinner so awkward in Hot Fuzz?
The instant an accelerating object has zero speed, is it speeding up, slowing down, or neither?
2 Managed Packages in 1 Dev Org
Do my partner and son need an SSN to be dependents on my taxes?
Will users know a CardView is clickable?
How to avoid offending original culture when making conculture inspired from original
What do I put on my resume to make the company i'm applying to think i'm mature enough to handle a job?
Right indicator flash-frequency has increased and rear-right bulb is out
What does a/.b[c][[1]] mean?
How do I run a script as sudo at boot time on Ubuntu 18.04 Server?
"Class 'Phar' not found" error setting up WP-CLI with Cygwin
How to address players struggling with simple controls?
Does knowing the surface area of all faces uniquely determine a tetrahedron?
In windows systems, is renaming files functionally similar to deleting them?
How to handle pexpect.expect with multiprocessing?
How should I log while using multiprocessing in Python?Keyboard Interrupts with python's multiprocessing PoolCan't pickle <type 'instancemethod'> when using multiprocessing Pool.map()Multiprocessing vs Threading PythonMultiprocessing: How to use Pool.map on a function defined in a class?Python multiprocessing pool.map for multiple argumentsDjango multiprocessing and database connectionsMultiprocessing - Pipe vs QueuePython multiprocessing PicklingError: Can't pickle <type 'function'>Django and multiprocessing AttributeError: Can't pickle local object
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to run a command which would print the output in console and send some output to serial port (USB0).
Based on the output from both the places, I need to decide on which path to take and continue the program. I would like to achieve this with pexpect as I need to add a timeout and look for a list of strings.
My intention is to run pexpect.expect commands for different pexpect instances in parallel.
I tried to create a minified test-case for this scenario.
Ex-1: This is what I'm expecting to do.
def run_cmd(a, host, rt):
b = a.expect([pexpect.EOF, pexpect.TIMEOUT, host])
rt[host] = b
if __name__ == '__main__':
jobs = []
rt = multiprocessing.Manager().dict()
host = 'a.b.c.d'
a = pexpect.spawn("ssh %s" % host)
p = multiprocessing.Process(target=run_cmd, args=(a, host, rt))
jobs.append(p)
p.start()
for proc in jobs:
proc.join()
pprint(rt.values())
Ex-2: This is working and I cannot launch a spawn for every call.
def run_cmd(host, rt):
a = pexpect.spawn("ssh %s" % host)
b = a.expect([pexpect.EOF, pexpect.TIMEOUT, host])
rt[host] = b
if __name__ == '__main__':
jobs = []
rt = multiprocessing.Manager().dict()
p = multiprocessing.Process(target=run_cmd, args=('a.b.c.d', rt))
jobs.append(p)
p.start()
for proc in jobs:
proc.join()
pprint(rt.values())
Ex-1 given above is resulting in the following error.
Process Process-2:
Traceback (most recent call last):
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/ptyprocess/ptyprocess.py", line 705, in isalive
pid, status = os.waitpid(self.pid, waitpid_options)
ChildProcessError: [Errno 10] No child processes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 23, in _wrap_ptyprocess_err
yield
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 682, in isalive
alive = ptyproc.isalive()
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/ptyprocess/ptyprocess.py", line 711, in isalive
'process. Did someone else call waitpid() ' +
ptyprocess.util.PtyProcessError: isalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() on our process?
multiprocessing python-3.7 pexpect
add a comment |
I'm trying to run a command which would print the output in console and send some output to serial port (USB0).
Based on the output from both the places, I need to decide on which path to take and continue the program. I would like to achieve this with pexpect as I need to add a timeout and look for a list of strings.
My intention is to run pexpect.expect commands for different pexpect instances in parallel.
I tried to create a minified test-case for this scenario.
Ex-1: This is what I'm expecting to do.
def run_cmd(a, host, rt):
b = a.expect([pexpect.EOF, pexpect.TIMEOUT, host])
rt[host] = b
if __name__ == '__main__':
jobs = []
rt = multiprocessing.Manager().dict()
host = 'a.b.c.d'
a = pexpect.spawn("ssh %s" % host)
p = multiprocessing.Process(target=run_cmd, args=(a, host, rt))
jobs.append(p)
p.start()
for proc in jobs:
proc.join()
pprint(rt.values())
Ex-2: This is working and I cannot launch a spawn for every call.
def run_cmd(host, rt):
a = pexpect.spawn("ssh %s" % host)
b = a.expect([pexpect.EOF, pexpect.TIMEOUT, host])
rt[host] = b
if __name__ == '__main__':
jobs = []
rt = multiprocessing.Manager().dict()
p = multiprocessing.Process(target=run_cmd, args=('a.b.c.d', rt))
jobs.append(p)
p.start()
for proc in jobs:
proc.join()
pprint(rt.values())
Ex-1 given above is resulting in the following error.
Process Process-2:
Traceback (most recent call last):
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/ptyprocess/ptyprocess.py", line 705, in isalive
pid, status = os.waitpid(self.pid, waitpid_options)
ChildProcessError: [Errno 10] No child processes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 23, in _wrap_ptyprocess_err
yield
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 682, in isalive
alive = ptyproc.isalive()
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/ptyprocess/ptyprocess.py", line 711, in isalive
'process. Did someone else call waitpid() ' +
ptyprocess.util.PtyProcessError: isalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() on our process?
multiprocessing python-3.7 pexpect
add a comment |
I'm trying to run a command which would print the output in console and send some output to serial port (USB0).
Based on the output from both the places, I need to decide on which path to take and continue the program. I would like to achieve this with pexpect as I need to add a timeout and look for a list of strings.
My intention is to run pexpect.expect commands for different pexpect instances in parallel.
I tried to create a minified test-case for this scenario.
Ex-1: This is what I'm expecting to do.
def run_cmd(a, host, rt):
b = a.expect([pexpect.EOF, pexpect.TIMEOUT, host])
rt[host] = b
if __name__ == '__main__':
jobs = []
rt = multiprocessing.Manager().dict()
host = 'a.b.c.d'
a = pexpect.spawn("ssh %s" % host)
p = multiprocessing.Process(target=run_cmd, args=(a, host, rt))
jobs.append(p)
p.start()
for proc in jobs:
proc.join()
pprint(rt.values())
Ex-2: This is working and I cannot launch a spawn for every call.
def run_cmd(host, rt):
a = pexpect.spawn("ssh %s" % host)
b = a.expect([pexpect.EOF, pexpect.TIMEOUT, host])
rt[host] = b
if __name__ == '__main__':
jobs = []
rt = multiprocessing.Manager().dict()
p = multiprocessing.Process(target=run_cmd, args=('a.b.c.d', rt))
jobs.append(p)
p.start()
for proc in jobs:
proc.join()
pprint(rt.values())
Ex-1 given above is resulting in the following error.
Process Process-2:
Traceback (most recent call last):
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/ptyprocess/ptyprocess.py", line 705, in isalive
pid, status = os.waitpid(self.pid, waitpid_options)
ChildProcessError: [Errno 10] No child processes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 23, in _wrap_ptyprocess_err
yield
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 682, in isalive
alive = ptyproc.isalive()
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/ptyprocess/ptyprocess.py", line 711, in isalive
'process. Did someone else call waitpid() ' +
ptyprocess.util.PtyProcessError: isalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() on our process?
multiprocessing python-3.7 pexpect
I'm trying to run a command which would print the output in console and send some output to serial port (USB0).
Based on the output from both the places, I need to decide on which path to take and continue the program. I would like to achieve this with pexpect as I need to add a timeout and look for a list of strings.
My intention is to run pexpect.expect commands for different pexpect instances in parallel.
I tried to create a minified test-case for this scenario.
Ex-1: This is what I'm expecting to do.
def run_cmd(a, host, rt):
b = a.expect([pexpect.EOF, pexpect.TIMEOUT, host])
rt[host] = b
if __name__ == '__main__':
jobs = []
rt = multiprocessing.Manager().dict()
host = 'a.b.c.d'
a = pexpect.spawn("ssh %s" % host)
p = multiprocessing.Process(target=run_cmd, args=(a, host, rt))
jobs.append(p)
p.start()
for proc in jobs:
proc.join()
pprint(rt.values())
Ex-2: This is working and I cannot launch a spawn for every call.
def run_cmd(host, rt):
a = pexpect.spawn("ssh %s" % host)
b = a.expect([pexpect.EOF, pexpect.TIMEOUT, host])
rt[host] = b
if __name__ == '__main__':
jobs = []
rt = multiprocessing.Manager().dict()
p = multiprocessing.Process(target=run_cmd, args=('a.b.c.d', rt))
jobs.append(p)
p.start()
for proc in jobs:
proc.join()
pprint(rt.values())
Ex-1 given above is resulting in the following error.
Process Process-2:
Traceback (most recent call last):
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/ptyprocess/ptyprocess.py", line 705, in isalive
pid, status = os.waitpid(self.pid, waitpid_options)
ChildProcessError: [Errno 10] No child processes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 23, in _wrap_ptyprocess_err
yield
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 682, in isalive
alive = ptyproc.isalive()
File "/proj/sival2/ctallapa/tools/apps/Anaconda3/5.3.0/lib/python3.7/site-packages/ptyprocess/ptyprocess.py", line 711, in isalive
'process. Did someone else call waitpid() ' +
ptyprocess.util.PtyProcessError: isalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() on our process?
multiprocessing python-3.7 pexpect
multiprocessing python-3.7 pexpect
asked Mar 25 at 4:08
Chaitanya TallapaneniChaitanya Tallapaneni
14
14
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331145%2fhow-to-handle-pexpect-expect-with-multiprocessing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331145%2fhow-to-handle-pexpect-expect-with-multiprocessing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown