asyncio - how to stop background task cleanly

2016-02-06 Thread Frank Millman
Hi all It is easy enough to set up a task to run in the background every 10 seconds using asyncio - async def background_task(): while True: await perform_task() await asyncio.sleep(10) asyncio.ensure_future(background_task()) When shutting the main program

Re: Daemon strategy

2016-02-06 Thread Ben Finney
Ian Kelly writes: > Depends on the version: > https://en.wikipedia.org/wiki/Windows_Services_for_UNIX > https://en.wikipedia.org/wiki/POSIX#POSIX_for_Windows > > Linux and FreeBSD are also not POSIX-certified, even though they > mostly comply. Should pip warn about those also? You're implying t

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Marko Rauhamaa
"Frank Millman" : > When shutting the main program down, I want to stop the task, but I > cannot figure out how to stop it cleanly - i.e. wait until it has > finished the current task and possibly performed some cleanup, before > continuing. Here (and really, only here) is where asyncio shows its

Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-06 Thread Shaunak Bangale
Hi Martin, Thanks for the detailed reply. I edited, saved and opened the file again. Still I am getting exactly the same error. Putting bigger chunk of code and the error again: # create socket s = socket.socket(socket.AF_INET) #create a SSL context with the recommended security settings for c

Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-06 Thread Shaunak Bangale
Hi Martin, Answering your questions below: On Fri, Feb 5, 2016 at 1:50 PM, Shaunak Bangale wrote: > Hi Martin, > > Thanks for the detailed reply. I edited, saved and opened the file again. > Still I am getting exactly the same error. > > Putting bigger chunk of code and the error again: > > >

Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-06 Thread Shaunak Bangale
I do have the initiation command defined. Just that I am not allowed to make the username, pwd public. I am absolutely sure I am running the same code. Now opened the same file with Python 3.5 shell and I get following error: from _ssl import RAND_status, RAND_egd, RAND_add ImportError: cannot

Re: Daemon strategy

2016-02-06 Thread Timo Furrer
As Ben already said .. either deploy to Unix systems or use subprocess.Popen and detach the process: from subprocess import Popenfrom win32process import DETACHED_PROCESS Popen(["YOURPROCESS"],creationflags=DETACHED_PROCESS,shell=True) On Fri, Feb 5, 2016 at 10:52 AM, Ben Finney wrote: > paul

Re: realtime output and csv files

2016-02-06 Thread Tim Chase
On 2016-02-06 02:53, Bernardo Sulzbach wrote: >> And even if you have things to escape or format correctly, the >> stdlib has a "csv" module that makes this trivially easy: >> > > I supposed it had one. Obviously, I've never used it myself, > otherwise I would be sure about its existence. Nice t

Re: realtime output and csv files

2016-02-06 Thread lucan
I wouldn't be surprised if a parser treated a value as text only because it has spaces on it. For OP, if you are going for this, I - personally - suggest sticking to "%d,%2d:%2d,%.1f". you're rightin fact importing datas in spreadsheet I've had some problems. I'll follow this suggestion. tnk

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87lh6ys052@elektro.pacujo.net... "Frank Millman" : > When shutting the main program down, I want to stop the task, but I > cannot figure out how to stop it cleanly - i.e. wait until it has > finished the current task and possibly performed some cleanu

python

2016-02-06 Thread jill davies
I would like to know how to open your python launcher to start coding on windows 8 the python version I have installed is python 3.5.1 but it keeps giving me an instillation set up Sent from Windows Mail -- https://mail.python.org/mailman/listinfo/python-list

Re: python

2016-02-06 Thread Mark Lawrence
On 06/02/2016 13:40, jill davies wrote: I would like to know how to open your python launcher to start coding on windows 8 the python version I have installed is python 3.5.1 but it keeps giving me an instillation set up hello and welcome. Your question has been asked and answered repeated

Re: _siftup and _siftdown implementation

2016-02-06 Thread srinivas devaki
As the comments in the heapq module says, in most of the cases (probability 0.837 [from knuth vol3]) the the new inserted element whose initial location is end of the array, which means that it will be larger than the `pos` children. So the old version and new version code is same in these cases be

Re: python

2016-02-06 Thread Joel Goldstick
On Sat, Feb 6, 2016 at 8:40 AM, jill davies wrote: > > > > > I would like to know how to open your python launcher to start coding on > windows 8 the python version I have installed is python 3.5.1 but it keeps > giving me an instillation set up > > > Sent from Windows Mail > -- > https://mail.py

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Marko Rauhamaa
"Frank Millman" : > "Marko Rauhamaa" wrote in message news:87lh6ys052@elektro.pacujo.net... >> You should >> >>await asyncio.wait(..., return_when=asyncio.FIRST_COMPLETED) >> >> to deal with multiple alternative stimuli. >> > > Thanks, Marko, that works very well. > > [...] > > Now I just

Re: Daemon strategy

2016-02-06 Thread paul . hermeneutic
On Fri, Feb 5, 2016 at 4:10 PM, Ben Finney wrote: > paul.hermeneu...@gmail.com writes: > >> On Fri, Feb 5, 2016 at 11:52 AM, Ben Finney >> wrote: >> > Since MS Windows lacks those facilities, ‘python-daemon’ can't use >> > them. >> >> As you might imagine, I am not always able to specify which O

Re: Daemon strategy

2016-02-06 Thread paul . hermeneutic
> As Ben already said .. either deploy to Unix systems or use > subprocess.Popen and detach the process: > > from subprocess import Popenfrom win32process import DETACHED_PROCESS > Popen(["YOURPROCESS"],creationflags=DETACHED_PROCESS,shell=True) This sounds promising. What are the common methods t

Re: Daemon strategy

2016-02-06 Thread Ian Kelly
On Sat, Feb 6, 2016 at 1:15 AM, Ben Finney wrote: > Ian Kelly writes: > >> Depends on the version: >> https://en.wikipedia.org/wiki/Windows_Services_for_UNIX >> https://en.wikipedia.org/wiki/POSIX#POSIX_for_Windows >> >> Linux and FreeBSD are also not POSIX-certified, even though they >> mostly

Issues with to run python

2016-02-06 Thread Dánisa Andrea Alejo García
Dear Technician, I am writing to you because I have downloaded Python,I have followed all the instructions, but for some reason I am unable to use it. I am sending to you a screen shot, so in that way you can have an idea of what is going on. I have already repaired and modified, but all

Re: Issues with to run python

2016-02-06 Thread Dánisa Andrea Alejo García
Sent from my iPhone On Feb 6, 2016, at 3:10 PM, Dánisa Andrea Alejo García mailto:alejo...@hotmail.com>> wrote: Dear Technician, I am writing to you because I have downloaded Python,I have followed all the instructions, but for some reason I am unable to use it. I am sending to you a

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Marko Rauhamaa
Marko Rauhamaa : > async def background_task(cancel_event): > while True: > await asyncio.wait( > perform_task, cancel_event.wait, > return_when=asyncio.FIRST_COMPETED) > if cancel_event_is_set() > break >

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-06 Thread Rick Johnson
On Wednesday, February 3, 2016 at 12:02:35 AM UTC-6, John Ladasky wrote: > Rick, you don't like Python? If i didn't like Python, then i would happily let it self- destruct, yes? The problem is, i *DO* like Python. Python2 was a great language, but python3 has been a disaster. Heck, even the BDF

Re: Issues with to run python

2016-02-06 Thread boB Stepp
On Sat, Feb 6, 2016 at 2:10 PM, Dánisa Andrea Alejo García wrote: > I am writing to you because I have downloaded Python,I have followed all the > instructions, but for some reason I am unable to use it. This is a very common question of late. If you search the list archives, you will probab

Re: Daemon strategy

2016-02-06 Thread Ben Finney
Ian Kelly writes: > On Sat, Feb 6, 2016 at 1:15 AM, Ben Finney wrote: > > You're implying that the PyPI trove category “Operating System :: POSIX” > > includes MS Windows? Or that it excludes Linux and FreeBSD? Or that it's > > meaningless? > > At least it's not very clear as to what OSes are su

Simple tkinter query about creating a tk,StringVar() failure

2016-02-06 Thread paul . hermeneutic
I know this may be more suited to the tutor list. I tried to subscribe, but no response yet. Why does this interactive instantiation fail when it seems to work when run in a script? (py35-64) C:\src\pygui>python Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)]

Re: Simple tkinter query about creating a tk,StringVar() failure

2016-02-06 Thread MRAB
On 2016-02-07 00:38:14, paul.hermeneu...@gmail.com wrote: I know this may be more suited to the tutor list. I tried to subscribe, but no response yet. Why does this interactive instantiation fail when it seems to work when run in a script? (py35-64) C:\src\pygui>python Python 3.5.1 (v3.5.1:37a

Re: Simple tkinter query about creating a tk,StringVar() failure

2016-02-06 Thread boB Stepp
On Sat, Feb 6, 2016 at 6:38 PM, wrote: > Why does this interactive instantiation fail when it seems to work > when run in a script? You have to establish your root window first: Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyrigh

Python's import situation has driven me to the brink of imsanity

2016-02-06 Thread dimva13
No, that's not a typo, it's the name of a package I created. :) The problems I have with python's import system are detailed in the README of my package here: https://github.com/vadimg/imsanity Basically, relative imports are broken if you like running scripts as executables, so the only real s

Re: Python's import situation has driven me to the brink of imsanity

2016-02-06 Thread Chris Angelico
On Sun, Feb 7, 2016 at 1:47 PM, wrote: > Imsanity allows you to make imports usable (not ideal, but at least usable) > for python projects without having to manage PYTHONPATHs or do whacky stuff > like running files with python -m or put even whackier boilerplate at the top > of every file. An

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-06 Thread INADA Naoki
Python 3 is a disaster because of incompatibility with Python 2. Python 3 itself is not so bad. We can help disaster recovery by stop using Python 2 as possible. Let's stop using legacy Python! On Sun, Feb 7, 2016 at 5:54 AM, Rick Johnson wrote: > On Wednesday, February 3, 2016 at 12:02:35 AM U

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-06 Thread Chris Angelico
On Sun, Feb 7, 2016 at 2:02 PM, INADA Naoki wrote: > Python 3 is a disaster because of incompatibility with Python 2. Python 3 > itself is not so bad. > We can help disaster recovery by stop using Python 2 as possible. > > Let's stop using legacy Python! > It's not even a disaster. It's fairly ea

Re: Daemon strategy

2016-02-06 Thread Michael Torrie
On 02/06/2016 09:04 AM, paul.hermeneu...@gmail.com wrote: > On Fri, Feb 5, 2016 at 4:10 PM, Ben Finney wrote: >> paul.hermeneu...@gmail.com writes: >> >>> On Fri, Feb 5, 2016 at 11:52 AM, Ben Finney >>> wrote: Since MS Windows lacks those facilities, ‘python-daemon’ can't use them. >>>

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:8737t5shhp@elektro.pacujo.net... > Actually, cancellation is specially supported in asyncio (https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel>) so this should do: async def background_task(): while True: a

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-06 Thread Steven D'Aprano
On Sunday 07 February 2016 14:02, INADA Naoki wrote: > Python 3 is a disaster because of incompatibility with Python 2. How is that a disaster? What is your criteria for deciding what is, and isn't, a disaster? According to TIOBE, Python's popularity continues to grow: http://www.tiobe.com/ind

Re: Python's import situation has driven me to the brink of imsanity

2016-02-06 Thread Kevin Conway
> My question is: is this crazy? Please tell me there's a better way and I just wasted my time creating this package. There is a better way and you have wasted your time creating this package. I hear your problem statement as asking two questions. The first is: What is the right way to include ex

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-06 Thread Paul Rubin
Steven D'Aprano writes: > According to TIOBE, Python's popularity continues to grow: > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html I wonder how much of that growth is Python 3 and how much is Python 2. I'm amazed there's still so much C being done. I meet good programmers a

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Frank Millman
"Frank Millman" wrote in message news:n96kjr$mvl$1...@ger.gmane.org... "Marko Rauhamaa" wrote in message news:8737t5shhp@elektro.pacujo.net... > Actually, cancellation is specially supported in asyncio ( https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel>) > so this

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-06 Thread Rustom Mody
On Sunday, February 7, 2016 at 8:04:42 AM UTC+1, Paul Rubin wrote: > Steven D'Aprano writes: > > According to TIOBE, Python's popularity continues to grow: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > I wonder how much of that growth is Python 3 and how much is Python

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-06 Thread Christian Gollwitzer
Am 07.02.16 um 08:04 schrieb Paul Rubin: Steven D'Aprano writes: According to TIOBE, Python's popularity continues to grow: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html I wonder how much of that growth is Python 3 and how much is Python 2. I'm amazed there's still so much

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-06 Thread Paul Rubin
Rustom Mody writes: > Data (science) is after all the hot subject > A programmer moving into that field typically starts with python > A statistician typically starts R There aren't THAT many statisticians out there, compared to programmers. -- https://mail.python.org/mailman/listinfo/python-lis

Re: asyncio - how to stop background task cleanly

2016-02-06 Thread Marko Rauhamaa
"Frank Millman" : > Alas, I spoke too soon. > > [...] > > If I press Ctrl+C, I get a traceback from the threading module - > >line 1288, in _shutdown >t.join() >line 1054, in join >self._wait_for_tstate_lock() >line 1070, in _wait_for_tstate_lock > KeyboardInterrupt > >