X-Received: by 10.66.240.206 with SMTP id wc14mr31909555pac.16.1447674028057; Mon, 16 Nov 2015 03:40:28 -0800 (PST) X-Received: by 10.50.122.103 with SMTP id lr7mr274306igb.10.1447674028023; Mon, 16 Nov 2015 03:40:28 -0800 (PST) Path: csiph.com!xmission!news.glorb.com!i2no3896797igv.0!news-out.google.com!l1ni6180igd.0!nntp.google.com!i2no3599584igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Mon, 16 Nov 2015 03:40:27 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=151.151.16.16; posting-account=1SpZ5woAAAA9asrWwzRpL93v3FfBemIc NNTP-Posting-Host: 151.151.16.16 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <73aaf275-3d2c-4148-8a43-204bd2cd128e@googlegroups.com> Subject: Re: help in pexpect multiprocessing From: harirammanohar159@gmail.com Injection-Date: Mon, 16 Nov 2015 11:40:28 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.python:98871 On Monday, 9 November 2015 18:07:36 UTC+5:30, hariramm...@gmail.com wrote: > Hi, >=20 > I am using multiprocessing with pexpect, issue is whenever i call a funct= ion which is having expect(), its throwing error which is genuine as multip= le threads are processing it same time (i/o prompt same time by multiple pr= ocesses..so issues in picture...), so i want to use lock for that section a= lone to avoid it, but still fails in implementing it...can you help me >=20 > username =3D input('Enter your username: ') > password =3D getpass.getpass() >=20 > s =3D pxssh.pxssh() > s.login ('host','username','password') > s.sendline ('ps -ef|grep java') > s.prompt(timeout=3D1) >=20 > Try 1: >=20 > if condition =3D=3D 'met': > np =3D len(list1) > p =3D multiprocessing.Pool(np) > p.map(stop, [(ds) for ds in list1]) >=20 > def stop(ds): > s.sendline ('cd /usr') > if condition: > lock =3D threading.Lock() > lock.acquire() > s.expect('Enter username:') > s.sendline ('user') > s.expect('Enter password:*') > s.sendline('pass') > lock.release() > s.prompt(timeout=3D200) > print('stopped ds...') >=20 > Try 2: >=20 > if condition =3D=3D 'met': > lock =3D Lock() > for ds in list1: > Process(target=3Dstop, args=3D(ds,lock)).start() >=20 > def stop(ds,l): > s.sendline ('cd /usr') > if condition: > l.acquire() > s.expect('Enter username:') > s.sendline ('user') > s.expect('Enter password:*') > s.sendline('pass') > l.release() > s.prompt(timeout=3D200) > print('stopped ds...') >=20 > Both are giving me same trace.. >=20 > pexpect.ExceptionPexpect: isalive() encountered condition where "terminat= ed" is 0, but there was no child process. Did someone else call waitpid() o= n our process? >=20 > Thanks in Advance Hey Lucena, Thank you for suggestion, yeah process queues doing the samething, creating= new sesssion for each process and executing simulatenously.. requirement i= s served.. but still i want to tackle the situation with locks, but not able to as thr= owing the below error. pexpect.ExceptionPexpect: isalive() encountered condition where "terminated= " is 0, but there was no child process. Did someone else call waitpid() on = our process?=20