Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88034
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'value,': 0.04; 'configure': 0.05; 'currently,': 0.09; 'executable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:skip:c 10': 0.09; 'runs': 0.10; 'python': 0.11; '(assuming': 0.16; 'advice:': 0.16; 'comparisons,': 0.16; 'finney': 0.16; 'helps.': 0.16; 'newer,': 0.16; 're-read': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'resist': 0.16; 'simpler,': 0.16; 'tempted': 0.16; 'timestamp': 0.16; 'modification': 0.16; 'library': 0.18; 'module': 0.19; 'file,': 0.19; "python's": 0.19; 'header:User-Agent:1': 0.23; 'config': 0.24; 'parse': 0.24; 'fine': 0.24; 'values': 0.27; 'header:X -Complaints-To:1': 0.27; 'record': 0.27; 'changed.': 0.31; 'convenience': 0.31; 'values.': 0.31; 'writes:': 0.31; 'file': 0.32; 'url:python': 0.33; '(e.g.': 0.33; 'common': 0.35; 'format.': 0.36; 'url:org': 0.36; 'seconds': 0.37; 'server': 0.38; 'ben': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'future': 0.60; 'hope': 0.61; 'url:3': 0.61; 'skip:n 10': 0.64; 'provide': 0.64; 'skip:\xe2 10': 0.65; 'received:125': 0.84; 'start.': 0.84; 'url:configparser': 0.84; 'wakes': 0.84; '8bit%:33': 0.91; 'hong': 0.91; 'kong': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Ben Finney <ben+python@benfinney.id.au> |
| Subject | Re: What is elegant way to do configuration on server app |
| Date | Thu, 26 Mar 2015 19:59:13 +1100 |
| References | <CAEKwp_FsbbAOrBm1h-CE1PS358pJBadJqNDi1CN7upC_s3nqCw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | jigong.madmonks.org |
| X-Public-Key-ID | 0xAC128405 |
| X-Public-Key-Fingerprint | 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 |
| X-Public-Key-URL | http://www.benfinney.id.au/contact/bfinney-pubkey.asc |
| X-Post-From | Ben Finney <bignose+hates-spam@benfinney.id.au> |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| Cancel-Lock | sha1:od7J/16i4GexCF0ONk02LgaDXic= |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| 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.189.1427360350.10327.python-list@python.org> (permalink) |
| Lines | 34 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1427360350 news.xs4all.nl 2978 [2001:888:2000:d::a6]:42172 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:88034 |
Show key headers only | View raw
Jerry OELoo <oyljerry@gmail.com> writes: > Currently, I can just think out that I put status into a configure > file, and service schedule read this file and get status value, That sounds like a fine start. Some advice: * You may be tempted to make the configuration file executable (e.g. Python code). Resist that temptation; keep it *much* simpler, a non-executable data format. Python's standard library has the ‘configparser’ module <URL:https://docs.python.org/3/library/configparser.html> to parse and provide the values from a very common configuration file format. Use that unless you have a good reason not to. * Your program can “poll” the configuration file to see whether it has changed. At startup, read the config file's modification timestamp <URL:https://docs.python.org/3/library/os.html#os.stat_result.st_mtime>. Make a part of your event loop (assuming your server runs an event loop) that wakes up every N seconds (e.g. every 60 seconds) and checkes the file's modification timestamp again; if it's newer, record that value for future comparisons, then re-read the file for its values. Hope that helps. -- \ “For your convenience we recommend courteous, efficient | `\ self-service.” —supermarket, Hong Kong | _o__) | Ben Finney
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: What is elegant way to do configuration on server app Ben Finney <ben+python@benfinney.id.au> - 2015-03-26 19:59 +1100
Re: What is elegant way to do configuration on server app Grant Edwards <invalid@invalid.invalid> - 2015-03-26 15:49 +0000
Re: What is elegant way to do configuration on server app Jerry OELoo <oyljerry@gmail.com> - 2015-03-27 16:28 +0800
Re: What is elegant way to do configuration on server app Grant Edwards <invalid@invalid.invalid> - 2015-03-27 16:28 +0000
Re: What is elegant way to do configuration on server app Chris Angelico <rosuav@gmail.com> - 2015-03-28 03:36 +1100
Re: What is elegant way to do configuration on server app Grant Edwards <invalid@invalid.invalid> - 2015-03-27 16:44 +0000
Re: What is elegant way to do configuration on server app Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 10:47 +0200
Re: What is elegant way to do configuration on server app Chris Angelico <rosuav@gmail.com> - 2015-03-28 00:12 +1100
Re: What is elegant way to do configuration on server app Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 15:23 +0200
Re: What is elegant way to do configuration on server app Chris Angelico <rosuav@gmail.com> - 2015-03-28 00:34 +1100
Re: What is elegant way to do configuration on server app Grant Edwards <invalid@invalid.invalid> - 2015-03-27 16:30 +0000
Re: What is elegant way to do configuration on server app Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 18:44 +0200
csiph-web