reg multiple login python

harirammanohar159 at gmail.com harirammanohar159 at gmail.com
Mon Oct 5 23:22:57 EDT 2015


On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm... at gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i can do one by one using for loop..
> 
> Thanks in advance.

Hi,

issue in implementing multiprocessing with pxssh, its working fine with normal operations but with pxssh its throwing error as below:
=========
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "./rmcomments.py", line 12, in xcute
    s = pxssh.pxssh()
  File "/usr/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/pxssh.py", line 91, in __init__
    spawn.__init__(self, None, timeout=timeout, maxread=maxread, searchwindowsize=searchwindowsize, logfile=logfile, cwd=cwd, env=env)
  File "/usr/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/__init__.py", line 493, in __init__
    fd = sys.__stdin__.fileno()
ValueError: I/O operation on closed file
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./rmcomments.py", line 23, in <module>
    output = p.map(xcute, [(srvrs) for srvrs in serverslist])
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 260, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 599, in get
    raise self._value
ValueError: I/O operation on closed file
======

Below is the code:
------------------------
serverslist = ['server1','server2']
username = 'user1'
password = 'password1'

def xcute(srvrs):
        s = pxssh.pxssh()
        s.login (srvrs, username, password)
        ---do stuff---
        s.sendline('logout')

np = len(serverslist)
p = multiprocessing.Pool(np)
output = p.map(xcute, [(srvrs) for srvrs in serverslist])


can any one help me out!!!!!
Thanks



More information about the Python-list mailing list