Message330028
I have some problems with asyncio on Windows - it block where it should go.
Documentation shows that it should work: https://docs.python.org/3/library/asyncio-stream.html -> StreamReader should return something.
See 1st example:
import asyncio
import sys
async def run_stockfish():
STOCKFISH_PATH = r'C:\root\chess\stockfish\stockfish 9\stockfish_9_x64_bmi2.exe'
stockfish = await asyncio.subprocess.create_subprocess_exec(
STOCKFISH_PATH,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
stockfish.stdin.write('uci'.encode())
while True:
# BUG? - blocks at this line - no output
line = await stockfish.stdout.read()
print(line)
await stockfish.wait()
if sys.platform == "win32":
asyncio.set_event_loop_policy(
asyncio.WindowsProactorEventLoopPolicy())
asyncio.run(run_stockfish(), debug=True)
1st output (nothing):
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
runfile('C:/Users/Cezary Wagner/PycharmProjects/stockfish-proxy/sandbox/async_proxy/s01_async_stockfish.py', wdir='C:/Users/Cezary Wagner/PycharmProjects/stockfish-proxy/sandbox/async_proxy')
2nd example:
import asyncio
import sys
async def run_stockfish():
STOCKFISH_PATH = r'C:\root\chess\stockfish\stockfish 9\stockfish_9_x64_bmi2.exe'
stockfish = await asyncio.subprocess.create_subprocess_exec(
STOCKFISH_PATH,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
stockfish.stdin.write('uci'.encode())
while True:
# BUG? - blocks at this line
line = await stockfish.stdout.readline()
print(line)
await stockfish.wait()
if sys.platform == "win32":
asyncio.set_event_loop_policy(
asyncio.WindowsProactorEventLoopPolicy())
asyncio.run(run_stockfish(), debug=True)
2nd output is little better (first line is read):
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
runfile('C:/Users/Cezary Wagner/PycharmProjects/stockfish-proxy/sandbox/async_proxy/s01_async_stockfish.py', wdir='C:/Users/Cezary Wagner/PycharmProjects/stockfish-proxy/sandbox/async_proxy')
b'Stockfish 9 64 BMI2 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott\r\n'
What should be done in both case (or maybe done):
Stockfish 9 64 BMI2 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
uci
id name Stockfish 9 64 BMI2
id author T. Romstad, M. Costalba, J. Kiiski, G. Linscott
option name Debug Log File type string default
option name Contempt type spin default 20 min -100 max 100
option name Threads type spin default 1 min 1 max 512
option name Hash type spin default 16 min 1 max 131072
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 500
option name Skill Level type spin default 20 min 0 max 20
option name Move Overhead type spin default 30 min 0 max 5000
option name Minimum Thinking Time type spin default 20 min 0 max 5000
option name Slow Mover type spin default 89 min 10 max 1000
option name nodestime type spin default 0 min 0 max 10000
option name UCI_Chess960 type check default false
option name SyzygyPath type string default <empty>
option name SyzygyProbeDepth type spin default 1 min 1 max 100
option name Syzygy50MoveRule type check default true
option name SyzygyProbeLimit type spin default 6 min 0 max 6
uciok |
|
Date |
User |
Action |
Args |
2018-11-17 11:52:54 | Cezary.Wagner | set | recipients:
+ Cezary.Wagner, paul.moore, tim.golden, asvetlov, zach.ware, yselivanov, steve.dower |
2018-11-17 11:52:54 | Cezary.Wagner | set | messageid: <1542455574.0.0.788709270274.issue35268@psf.upfronthosting.co.za> |
2018-11-17 11:52:53 | Cezary.Wagner | link | issue35268 messages |
2018-11-17 11:52:53 | Cezary.Wagner | create | |
|