Re: Altering sys.argv on startup in Python 2

2016-06-13 Thread Adam Bartoš
Thank you very much, the hook gets invoked at the right place. Adam Bartoš -- https://mail.python.org/mailman/listinfo/python-list

Altering sys.argv on startup in Python 2

2016-06-12 Thread Adam Bartoš
27;sys'] or sys.__dict__ to something that runs my code on PySys_SetArgv, but that doesn't work since PySys_SetArgv doesn't invoke any hooks like __setitem__ on sys.__dict__. So is there any way how to automatically run my code after sys.argv was set but before executing the main script

Re: Python Questions - July 25, 2015

2015-07-26 Thread Adam Bartoš
> How do you actually install Numpy in Windows? In theory, `pip install numpy` should work, but there are currently no wheels for Windows, see https://github.com/numpy/numpy/issues/5479. Try `pip install -i https://pypi.binstar.org/carlkl/simple numpy` (see last posts in the issue). Adam Bar

Capturing stdin and stdout using ctypes

2015-07-26 Thread Adam Bartoš
Hello, how can I capture C stdin and stdout file pointers using ctypes in Python 3? I want them to be able to call PyOS_Readline via ctypes. Thank you, Adam Bartoš -- https://mail.python.org/mailman/listinfo/python-list

Re: An asyncio example

2015-07-05 Thread Adam Bartoš
Terry Reedy wrote: > I suggest you post your minimal example there. User interest in an > issue being fixed and willingness to test patches can help motivate. I've done it. Thank you for help. -- https://mail.python.org/mailman/listinfo/python-list

Re: An asyncio example

2015-07-04 Thread Adam Bartoš
On Sat, Jul 4, 2015 at 1:07 PM, Adam Bartoš wrote: > On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa >> wrote: >> > >> >>> 1) is there a way to close just one direction of the connection? >> >> >> >> No. SOCK_STREAM sockets are always bidi

Re: An asyncio example

2015-07-04 Thread Adam Bartoš
> > On Fri, Jul 3, 2015 at 9:14 AM, Marko Rauhamaa > wrote: > > > >>> 1) is there a way to close just one direction of the connection? > >> > >> No. SOCK_STREAM sockets are always bidirectional. > > > > socket.shutdown(socket.SHUT_WR) does the trick. > > > > I think the asyncio.StreamWriter.write_

Re: An asyncio example

2015-07-04 Thread Adam Bartoš
On Sat, Jul 4, 2015 at 8:45 AM, Adam Bartoš wrote: > On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš wrote: >>> >>>> Ian Kelly: >>>> >>> >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the >>>> loop >>

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
> > On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš wrote: >> >>> Ian Kelly: >>> >> >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the >>> loop >>> >> >> is that desired behavior? And why? >>

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš wrote: > Ian Kelly: > > >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the > loop, > >> is that desired behavior? And why? > > > > I don't think so. When I tried this locally (usin

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
>> Marko Rauhamaa: >>> socket.shutdown(socket.SHUT_WR) does the trick. >>> >>> I think the asyncio.StreamWriter.write_eof() is the high-level >>> equivalent. >> >> You are right that writer.write_eof() behaves like >> writer.transport.get_extra_info("socket").shutdown(socket.SHUT_WR) – >> the serve

Re: An asyncio example

2015-07-03 Thread Adam Bartoš
Ian Kelly: >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the loop, >> is that desired behavior? And why? > > I don't think so. When I tried this locally (using Python 3.4.0, so > replacing "async def" with "def" and "await" with "yield from" and > "loop.create_task" with "as

An asyncio example

2015-07-03 Thread Adam Bartoš
oop.create_task(server_coro) client_task = loop.create_task(client_coro) return client_task loop = asyncio.get_event_loop() task = loop.run_until_complete(connect(loop)) loop.run_until_complete(task) Thank you, Adam Bartoš -- https://mail.python.org/mailman/listinfo/python-list