unode / panyc

Command-line interface to Cisco's AnyConnect VPN.
GNU General Public License v3.0
11 stars 4 forks source link

Error on multithreading #1

Open CeeBeeCee opened 3 years ago

CeeBeeCee commented 3 years ago

Hello,

First of all, thanks for writing this library! I needed to query the state of Cisco Anywhere and this is exactly what I needed. The only problem is that I need to execute this using multi-threading and I get this error while doing so :

"cisco_anyconnect_cli\cisco_anyconnect.py", line 32, in state File "subprocess.py", line 728, in init File "subprocess.py", line 1025, in _get_handles OSError: [WinError 6] The handle is invalid

To get past this error, we need to add stdin and creationflags as follows in the state method. Could you please make these changes?

Thanks

def state(self) -> str:
    """
    Get connection state. Return actual state or Unknown if result was unexpected
    """
    proc = Popen([self.bin, "state"], stdout=PIPE, stderr=STDOUT, **stdin=DEVNULL, creationflags=0x08000000**)
unode commented 3 years ago

Hi Sib,

panyc uses pexpect to interact with AnyConnect, it does not use Popen directly so I'm not sure how to implement your suggestion.

It has been a while since I wrote this tool and I'm not on Windows so I can't really test your use-case. Would you be able to provide a pull request with the proposed changes?