@@ -357,7 +357,7 @@ def init_control(self, context):
357357 self .control_port = self ._bind_socket (self .control_socket , self .control_port )
358358 self .log .debug ("control ROUTER Channel on port: %i" % self .control_port )
359359
360- self .debugpy_socket = zmq_anyio .Socket (context , zmq .STREAM )
360+ self .debugpy_socket = zmq_anyio .Socket (context . socket ( zmq .STREAM ) )
361361 self .debugpy_socket .linger = 1000
362362
363363 self .debug_shell_socket = zmq_anyio .Socket (context .socket (zmq .DEALER ))
@@ -701,14 +701,24 @@ def start(self) -> None:
701701 if self .poller is not None :
702702 self .poller .start ()
703703 backend = "trio" if self .trio_loop else "asyncio"
704- run (self .main , backend = backend )
704+ run (partial ( self .main , backend ) , backend = backend )
705705 return
706706
707707 async def _wait_to_enter_eventloop (self ):
708708 await self .kernel ._eventloop_set .wait ()
709709 await self .kernel .enter_eventloop ()
710710
711- async def main (self ):
711+ async def main (self , backend : str ):
712+ if backend == "asyncio" and sys .platform == "win32" :
713+ import asyncio
714+
715+ policy = asyncio .get_event_loop_policy ()
716+ if policy .__class__ .__name__ == "WindowsProactorEventLoopPolicy" :
717+ from anyio ._core ._asyncio_selector_thread import get_selector
718+ selector = get_selector ()
719+ selector ._thread .pydev_do_not_trace = True
720+ #selector._thread.is_pydev_daemon_thread = True
721+
712722 async with create_task_group () as tg :
713723 tg .start_soon (self ._wait_to_enter_eventloop )
714724 tg .start_soon (self .kernel .start )
0 commit comments