Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

too many open files / vty #7

Open
smain opened this issue Sep 20, 2017 · 0 comments
Open

too many open files / vty #7

smain opened this issue Sep 20, 2017 · 0 comments

Comments

@smain
Copy link

smain commented Sep 20, 2017

if wrapper used excesivly, asking many properties on many hosts, ist crashs with too many open files error.

Traceback
(most recent call last):
File "/opt/test/wmiserv/service_wmi.py", line 418, in get_df
output=(wmic.query("SELECT Name,FileSystem,Size,FreeSpace FROM Win32_Logicaldisk"))
File "/usr/lib/python2.7/site-packages/wmi_client_wrapper/wrapper.py", line 92, in query
output = sh.wmic(*arguments)
File "/usr/lib/python2.7/site-packages/sh.py", line 1028, in call
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/usr/lib/python2.7/site-packages/sh.py", line 490, in init
self.call_args, pipe)
File "/usr/lib/python2.7/site-packages/sh.py", line 1192, in init
self._slave_stdin_fd, self._stdin_fd = os.pipe()
OSError: [Errno 24] Too many open files

This is because there is no exception handling, no timeouts and piped input for no reason.

original:
line 92 : output = sh.wmic(*arguments)

fix seems to works for me:

  try:
       output = sh.wmic(*arguments,_timeout=35,_tty_in=True,_new_session=False)
   except sh.TimeoutException:
       output = "timeout"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant