You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When executing multiple instances of a script, wexpect overloads on the same port and will typically timeout on the first use of expect(). In some cases, I've observed a race condition where the ConsoleReader of the second process connects to the port of the first and things get a little mixed up...
To Reproduce
Call this script from two seperate terminals without specifying a port. The second instance will time-out on expect('>').
Then call them again but specify unique ports. All is well.
importwexpectimportosimportsyspid=os.getpid()
iflen(sys.argv) >1:
port=sys.argv[1]
else:
port=Noneprint(f'Started process {pid}, using port {port}')
ifnotport:
child=wexpect.host.SpawnSocket(f'cmd.exe', interact=True)
else:
child=wexpect.host.SpawnSocket(f'cmd.exe', interact=True, port=int(port))
child.expect('>')
print("Prompt detected...")
string=f'echo Hello From {pid}'child.sendline(string)
child.expect(string)
print(child.match)
wait=input("Press Enter to close.")
An obvious workaround is to specify a unique port to the constructor but it took me a while to work out what was going on...
Expected behavior
If a port is not specified, I would expect the default port to be a random free port.
Or at a minimum, maybe this behaviour could be documented?
Screenshots
N/A
Environment:
Windows 10.0.19044.2132
Python 3.7.0
wexpect 4.0.0
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Describe the bug
When executing multiple instances of a script, wexpect overloads on the same port and will typically timeout on the first use of
expect()
. In some cases, I've observed a race condition where theConsoleReader
of the second process connects to the port of the first and things get a little mixed up...To Reproduce
Call this script from two seperate terminals without specifying a port. The second instance will time-out on
expect('>')
.Then call them again but specify unique ports. All is well.
An obvious workaround is to specify a unique port to the constructor but it took me a while to work out what was going on...
Expected behavior
If a port is not specified, I would expect the default port to be a random free port.
Or at a minimum, maybe this behaviour could be documented?
Screenshots
N/A
Environment:
Additional context
N/A
The text was updated successfully, but these errors were encountered: