jborean93 / pypsrp

PowerShell Remoting Protocol for Python
MIT License
324 stars 49 forks source link

`copy()` timeout #182

Open shreyamalviya opened 9 months ago

shreyamalviya commented 9 months ago

Hi,

In our code, we're copying a file to a remote machine using pypsrp.Client.copy: https://github.com/jborean93/pypsrp/blob/d2a3eca257230e40354d39ca008639992f8495a4/src/pypsrp/client.py#L69-L94

There seems to be no way to set a timeout for the operation. Is there some way to do this that I'm missing or is this not a feature that's implemented yet?

jborean93 commented 9 months ago

There is no way to currently do so, you can configure the socket timeouts like a connection and read timeout but it will continue to write to the file during that time.

shreyamalviya commented 9 months ago

you can configure the socket timeouts like a connection and read timeout

I don't think I understand. How?

jborean93 commented 8 months ago

When you create the client you specify it through the kwargs

from pypsrp.client import Client

with Client("server", connection_timeout=30, read_timeout=30) as client:
    client.copy(...)

The kwargs here are passed through to the WSMan object https://github.com/jborean93/pypsrp/blob/d2a3eca257230e40354d39ca008639992f8495a4/src/pypsrp/wsman.py#L109-L132. Please take not that if you set read_timeout, then operation_timeout should also be set to something that is lower than it.

Remember that this won't set the global timeout for the operation, there is no way to do so right now. This only configures the timeout it takes to connect to the host and the time in which it will wait for a response on any WSMan request sent during this process.