Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76758 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2014-08-22 10:26 +1000 |
| Last post | 2014-08-23 06:32 +1000 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Python vs C++ Chris Angelico <rosuav@gmail.com> - 2014-08-22 10:26 +1000
Re: Python vs C++ CHIN Dihedral <dihedral88888@gmail.com> - 2014-08-22 12:00 -0700
Halfway point between interactive and daemon? Travis Griggs <travisgriggs@gmail.com> - 2014-08-22 12:27 -0700
Re: Halfway point between interactive and daemon? Marko Rauhamaa <marko@pacujo.net> - 2014-08-22 22:49 +0300
Re: Halfway point between interactive and daemon? Chris Angelico <rosuav@gmail.com> - 2014-08-23 06:32 +1000
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-08-22 10:26 +1000 |
| Subject | Re: Python vs C++ |
| Message-ID | <mailman.13263.1408667169.18130.python-list@python.org> |
On Fri, Aug 22, 2014 at 4:05 AM, Joseph Martinot-Lagarde <joseph.martinot-lagarde@m4x.org> wrote: > For information, Cython works with C++ now: > http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html. Now isn't that cool! Every time Cython gets discussed, I get a renewed desire to learn it. Trouble is, I don't have any project that calls for it - there's nothing I'm desperately wanting to do that involves both Python and C/C++. Anyone got any suggestions? :) ChrisA
[toc] | [next] | [standalone]
| From | CHIN Dihedral <dihedral88888@gmail.com> |
|---|---|
| Date | 2014-08-22 12:00 -0700 |
| Message-ID | <0f0ef37d-7d09-483f-8f9b-c63c444f1ea7@googlegroups.com> |
| In reply to | #76758 |
On Friday, August 22, 2014 8:26:00 AM UTC+8, Chris Angelico wrote: > On Fri, Aug 22, 2014 at 4:05 AM, Joseph Martinot-Lagarde > > <joseph.martinot-lagarde@m4x.org> wrote: > > > For information, Cython works with C++ now: > > > http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html. > > > > Now isn't that cool! > > > > Every time Cython gets discussed, I get a renewed desire to learn it. > > Trouble is, I don't have any project that calls for it - there's > > nothing I'm desperately wanting to do that involves both Python and > > C/C++. Anyone got any suggestions? :) > > > > ChrisA Don't you use C as a portable assembler in Python? PYTHON->C->HW_BOUNDED_ASSEMBLY That is the way to speed up python programs using critical heavy computing functions.
[toc] | [prev] | [next] | [standalone]
| From | Travis Griggs <travisgriggs@gmail.com> |
|---|---|
| Date | 2014-08-22 12:27 -0700 |
| Subject | Halfway point between interactive and daemon? |
| Message-ID | <mailman.13302.1408735687.18130.python-list@python.org> |
| In reply to | #76808 |
I have a python3 program that performs a long running service on a semi embedded linux device. I've been in the prototyping stage. I just run it from the command line and use print() statements to let me know the thing is making acceptable process. At some point, I need to properly daemonize it. Write an init script, find a logging framework/module, batton all the hatches down, so to speak. I’m curious if there’s a technique one could use to get half way there. Basically, with minimal modifications, I’d like to get it running at startup. So I can put a line like this in rc.local nohup python3 myMain.py 2>&1 > /var/log/mylog.log & Then I can “check” on it when I need to with a tail -f /var/log/mylog.log. But then I have the problem of managing the log size. And also I either have to wait for stdout to flush, or insert sys.stdout.flush() after any of my print()’s. I haven’t done a lot of these daemon processes (and this is my first with python), so I was curious what those with experience do here.
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-08-22 22:49 +0300 |
| Subject | Re: Halfway point between interactive and daemon? |
| Message-ID | <87wqa09ufm.fsf@elektro.pacujo.net> |
| In reply to | #76811 |
Travis Griggs <travisgriggs@gmail.com>: > nohup python3 myMain.py 2>&1 > /var/log/mylog.log & I don't recommend this (ubiquitous) technique. You should keep your daemon in the foreground until it has reserved and initialized all the resources it needs and daemonize only then. That way the caller does not have to guess when the service is really available. The proper daemonization procedure is here: <URL: http://code.activestate.com/recipes/66012-fork-a-dae mon-process-on-unix/> Now, with the new systemd standard, there is a way for you to inform the system when a service is up even after backgrounding. I have no personal experience with that technique. Marko
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-08-23 06:32 +1000 |
| Subject | Re: Halfway point between interactive and daemon? |
| Message-ID | <mailman.13308.1408739570.18130.python-list@python.org> |
| In reply to | #76808 |
On Sat, Aug 23, 2014 at 5:27 AM, Travis Griggs <travisgriggs@gmail.com> wrote: > I’m curious if there’s a technique one could use to get half way there. Basically, with minimal modifications, I’d like to get it running at startup. Okay, hold on a minute there. There are two quite separate things here: daemonization, and starting on system startup. Daemonization is actually unnecessary to the latter, if you use a modern init system. Just write your program to never fork, and either Upstart or systemd will happily monitor it. Just create a unit file, something like this: [Unit] Description=Yosemite Project [Service] Environment=DISPLAY=:0.0 User=whichever_user_to_run_as ExecStart=/usr/bin/python /path/to/your/script # If the network isn't available yet, restart until it is. Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.target $ systemctl --system daemon-reload $ systemctl enable yos.service $ systemctl start yos.service (Feel free to steal that for your own purposes. It came from my MIT-licensed videos server project "Yosemite".) Daemonization should be optional. The above unit file works fine for something that doesn't fork itself away. (I'm not sure how systemd works with daemonizing processes, never tried. In any case, it's unnecessary.) If you do need it (so the user can start your program from the command line), I strongly recommend picking up a module off PyPI; there are actually a lot of little details that people will expect you to have gotten right. May as well bury it all away in a little daemonize() call :) ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web