Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77779
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <airween@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'root': 0.05; 'python3': 0.07; 'utf-8': 0.07; '"__main__":': 0.09; '#print': 0.09; '__name__': 0.09; 'failed:': 0.09; 'main()': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'creates': 0.14; 'thread': 0.14; 'times,': 0.14; "'__main__':": 0.16; '(%s)"': 0.16; 'fork': 0.16; 'main():': 0.16; 'packets.': 0.16; 'subject:under': 0.16; 'sys.exit(0)': 0.16; 'sys.exit(1)': 0.16; 'threads,': 0.16; 'travis': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'basically': 0.19; 'thu,': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'this:': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'reporting': 0.29; 'that.': 0.31; '-0700,': 0.31; 'layer': 0.31; 'sep': 0.31; 'running': 0.33; 'skip:# 10': 0.33; 'skip:t 40': 0.33; 'board': 0.35; 'except': 0.35; 'received:google.com': 0.35; 'skip:> 10': 0.36; 'subject:service': 0.36; 'subject:?': 0.36; 'two': 0.37; 'depends': 0.38; 'mine': 0.38; 'does': 0.39; 'skip:t 30': 0.61; 'from:charset:utf-8': 0.61; 'content-disposition:inline': 0.62; 'address': 0.63; 'networking': 0.64; 'skip:\xe2 10': 0.65; 'to:addr:gmail.com': 0.65; 'periodically': 0.68; 'serial': 0.72; '8bit%:43': 0.74; '2014,': 0.84; 'it\xe2\x80\x99s': 0.84; 'received:86': 0.91; 'received:hu': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=KOv9dyR7IYOrh3yEfX7pYEgOrymlmetuNiVL6jIybc0=; b=k0gdZruy2Xh9ivF+2Ie8CAdkQQF8QSpk7ZX0Wp/4UTcNi0j24f53VMOrafRZC6eJPZ EFb7mo1bmAUbkk8ScDUgyCm3AbROaB9uVGQ98hFKjq/LjlJbpK2lQ7WFSlTy9nWAfsVQ 4hZYGR83uMN6w12V0xjV4BPnN65/iE2anoGai1KhjX2gisii/TuhvtDkovoreHO5UZyl bWoMOI5Wt1fK/UQkwQlMKeZhXPwZAickocG7kMr2Uf6D4C2Fu90E9I+K1PNsh2+oIUjS yUZPwSlI0oAL7F9VGFif2h6cBK99uBAAGRi5EhnmIEGmBPZ3ikNFLKvJs2ufVXOzbsnf tQ6g== |
| X-Received | by 10.180.39.200 with SMTP id r8mr5714918wik.23.1410470964248; Thu, 11 Sep 2014 14:29:24 -0700 (PDT) |
| Date | Thu, 11 Sep 2014 23:29:21 +0200 |
| From | Ervin Hegedüs <airween@gmail.com> |
| To | Travis Griggs <travisgriggs@gmail.com> |
| Subject | Re: Example of python service running under systemd? |
| References | <FE4C3550-8958-4F72-8AFE-62AA7248D6AF@gmail.com> <CAMw+j7+LQL_+77ejCFVSqWap7Rk9gS_Wu5d3y0gT1UpB8hiZAA@mail.gmail.com> <6B97B7A5-0816-401E-9BDD-A23FFC646985@gmail.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Disposition | inline |
| Content-Transfer-Encoding | 8bit |
| In-Reply-To | <6B97B7A5-0816-401E-9BDD-A23FFC646985@gmail.com> |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13943.1410470965.18130.python-list@python.org> (permalink) |
| Lines | 67 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1410470965 news.xs4all.nl 2841 [2001:888:2000:d::a6]:47067 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77779 |
Show key headers only | View raw
Hi Travis,
On Thu, Sep 11, 2014 at 02:06:48PM -0700, Travis Griggs wrote:
>
> On Sep 11, 2014, at 11:18 AM, Chris “Kwpolska” Warrick <kwpolska@gmail.com> wrote:
>
> > Depends what you want.
>
> Mine is not a web service. My main.py looks like this:
>
> #!/usr/bin/env python3
>
> import cycle
> import pushTelemetry
> from threading import Thread
>
> def main():
> Thread(target=pushTelemetry.udpLoop).start()
> Thread(target=cycle.cycleLoop).start()
>
> if __name__ == '__main__':
> main()
>
> It basically creates two threads, one which does some local processing and control, the other which periodically does reporting via udp packets. I use the dual threads because they both work with a shared serial port at times, so I have to synchronize access through that.
>
> What I want is to have this startup, after my board has it’s networking layer up and running (and hopefully a valid ip address by then), and to just keep running forever
may be you think about the fork(), eg:
if __name__ == "__main__":
...other codes, eg. drop root privileges, ...
...check arguments...
try:
pid = os.fork()
if pid > 0:
#print "Daemon started (pid: %d)" % (pid)
sys.exit(0)
except OSError, e:
print >>sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror)
sys.exit(1)
os.chdir("/")
os.setsid()
os.umask(0)
# do second fork
try:
pid = os.fork()
if pid > 0:
#print "Daemon started (pid: %d)" % (pid)
sys.exit(0)
except OSError, e:
print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror)
sys.exit(1)
main()
regards,
a.
--
I � UTF-8
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Example of python service running under systemd? Ervin Hegedüs <airween@gmail.com> - 2014-09-11 23:29 +0200
csiph-web