简体   繁体   English

你如何关闭 Pywinrm 会话?

[英]how do you close a Pywinrm session?

hello I'm using PyWinRM to poll a remote windows server.您好,我正在使用 PyWinRM 轮询远程 Windows 服务器。

s = winrm.Session('10.10.10.10', auth=('administrator', 'password')) s = winrm.Session('10.10.10.10', auth=('管理员', '密码'))

As there is no s.close() function available, I am worried about leaking file descriptors.由于没有 s.close() 函数可用,我担心泄漏文件描述符。

I've checked by using lsof -p <myprocess> | wc -l我已经使用lsof -p <myprocess> | wc -l进行了检查lsof -p <myprocess> | wc -l lsof -p <myprocess> | wc -l and my fd count is stable but my google searches show that ansible had fd leaks previously; lsof -p <myprocess> | wc -l并且我的 fd 计数稳定,但我的谷歌搜索显示 ansible 之前有 fd 泄漏; ansible relies on pywinrm to manage remote window hosts as well ansible 也依赖 pywinrm 来管理远程窗口主机

kindly advice, thanks!恳请指教,谢谢!

Actually, I had a quick look at the code of wirm (as of 20201117) and the "Session" is not an actual session in the traditional sense, but only an object holding the creds to authenticate.实际上,我快速查看了 wirm 的代码(截至 20201117),“会话”不是传统意义上的实际会话,而只是一个持有要进行身份验证的凭据的对象。

Each time run_cmd or run_ps is invoked, a session in opened on the target and closed on completion of the task.每次调用 run_cmd 或 run_ps 时,都会在目标上打开一个会话,并在任务完成时关闭。 So there's nothing to close, really.所以没有什么可以关闭的,真的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM