Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78292
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <a.nandagoban@traxens.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'subject:Windows': 0.02; 'subject:Python': 0.06; 'method.': 0.07; 'skip:p 60': 0.07; 'wednesday,': 0.07; '__name__': 0.09; 'skip:_ 80': 0.09; 'skip:t 60': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'windows': 0.15; '"python': 0.16; "'__main__':": 0.16; '23,': 0.16; '24,': 0.16; 'addr': 0.16; 'addr)': 0.16; 'blocks': 0.16; 'msg:': 0.16; 'skip:a 130': 0.16; 'skip:l 130': 0.16; 'skip:t 130': 0.16; '\xc2\xa0i': 0.16; 'wrote:': 0.18; 'app': 0.19; '<': 0.19; 'example': 0.22; 'cc:addr:python.org': 0.22; 'id:': 0.23; 'error': 0.23; 'example.': 0.24; 'stopping': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'logging': 0.26; 'pass': 0.26; 'code:': 0.26; 'skip:_ 20': 0.27; 'header:In-Reply-To:1': 0.27; 'skip:p 30': 0.29; 'am,': 0.29; 'skip:( 40': 0.30; 'skip:( 20': 0.30; 'code': 0.31; 'sep': 0.31; "skip:' 40": 0.31; 'skip:s 70': 0.31; 'class': 0.32; 'run': 0.32; 'implemented': 0.33; 'skip:_ 10': 0.34; 'problem': 0.35; 'connection': 0.35; 'except': 0.35; 'skip:s 30': 0.35; 'case,': 0.35; 'more,': 0.35; 'one,': 0.35; 'but': 0.35; 'there': 0.35; 'url:rec-html40': 0.35; 'false': 0.36; 'skip:s 60': 0.36; 'method': 0.36; 'url:org': 0.36; 'received:it': 0.37; 'url:microsoft': 0.37; 'server': 0.38; 'skip:& 10': 0.38; 'thank': 0.38; 'gmail': 0.38; 'url:office': 0.38; 'url:schemas': 0.38; 'url:omml': 0.39; 'url:2004': 0.39; 'skip:& 20': 0.39; 'url:12': 0.39; 'skip:p 20': 0.39; 'skip:t 30': 0.61; 'simple': 0.61; 're:': 0.63; 'skip:n 10': 0.64; '8bit%:95': 0.64; 'to:addr:gmail.com': 0.65; 'received:46': 0.66; 'sample': 0.67; '8bit%:74': 0.68; 'skip:w 40': 0.68; 'skip:w 30': 0.69; '8bit%:84': 0.69; '8bit%:100': 0.72; '8bit%:94': 0.72; '8bit%:57': 0.74; '8bit%:97': 0.74; '2014,': 0.84; '8bit%:45': 0.84; '8bit%:60': 0.84; '8bit%:77': 0.84; '8bit%:82': 0.84; 'skip:s 80': 0.84; '8bit%:54': 0.91; '8bit%:58': 0.91; '8bit%:67': 0.93; '8bit%:90': 0.93; 'url:cc': 0.98 |
| X-Rid | a.nandagoban@traxens.com@46.218.201.210 |
| From | "Arulnambi Nandagoban" <a.nandagoban@traxens.com> |
| To | "'Gmail'" <mrjean1@gmail.com> |
| References | <460EC810-C983-43FB-90AF-315D5DF5174B@Gmail.com> <000f01cfd7c7$64caa6a0$2e5ff3e0$@traxens.com> <1570DB93-532A-4A9D-A5DF-20F3D6DEE3B8@Gmail.com> |
| In-Reply-To | <1570DB93-532A-4A9D-A5DF-20F3D6DEE3B8@Gmail.com> |
| Subject | RE: Python as Windows Service |
| Date | Wed, 24 Sep 2014 16:49:21 +0200 |
| MIME-Version | 1.0 |
| Content-Type | multipart/alternative; boundary="----=_NextPart_000_006D_01CFD817.7E1BC3F0" |
| X-Mailer | Microsoft Outlook 14.0 |
| Thread-Index | AQMmDHCi6BWgmX1lkhy8KNLP6CkI3AI2vGlAAhPsf2eZQZSy4A== |
| Content-Language | en-us |
| 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.14317.1411570176.18130.python-list@python.org> (permalink) |
| Lines | 697 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1411570176 news.xs4all.nl 2945 [2001:888:2000:d::a6]:41878 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:78292 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
De : Gmail [mailto:mrjean1@gmail.com]
Envoyé : Wednesday, September 24, 2014 2:41 PM
À : Arulnambi Nandagoban
Objet : Re: Python as Windows Service
Also, this may work for you
<http://nssm.cc/description>
<http://nssm.cc/usage>
NSSM installs an existing app as a service.
/Jean
On Sep 24, 2014, at 3:16 AM, "Arulnambi Nandagoban" <a.nandagoban@traxens.com> wrote:
De : MrJean1 [mailto:mrjean1@gmail.com]
Envoyé : Tuesday, September 23, 2014 5:55 PM
À : a.nandagoban@traxens.com
Objet : Python as Windows Service
Here's one, simple example
<http://stackoverflow.com/questions/32404/is-it-possible-to-run-a-python-script-as-a-service-in-windows-if-possible-how>
There are more, just search for "Python Windows Service" for example.
/Jean
Thank you !!!
--
Nambi
Thank you again !!!
I managed to run the server as as service with help of sample code provided in <http://stackoverflow.com/questions/32404/is-it-possible-to-run-a-python-script-as-a-service-in-windows-if-possible-how .
I found some problem in stopping the service. I feel it because of socket.accept() which blocks. This the class where I implemented the server in the main method.
class TraxServerSvc (win32serviceutil.ServiceFramework):
_svc_name_ = "Testserver"
_svc_display_name_ = "Pytestserver"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
self.hWaitStop = win32event.CreateEvent(None,0,0,None)
self.sloop = True
self.serversock = 0
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
self.sloop = False
def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_,''))
self.main()
def main(self):
self.serversock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.serversock.bind(server_config())
self.serversock.listen(5)
while (win32event.WaitForSingleObject(self.hWaitStop, 0) == 258):
try:
clientsock, addr = self.serversock.accept()
Pysconfig.logger.info('...connected from: %s', addr) # logging
thread.start_new_thread(handler, (clientsock, addr))
Pysconfig.logger.info('Thread ID: %s', thread.get_ident()) # logging
except socket.error, msg:
Pysconfig.logger.info('Failed to create socket. Error code: ' + str(msg[0]) + ' , Error message : ' + msg[1])
pass
self.serversock.shutdown(socket.SHUT_RDWR)
self.serversock.close()
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_,''))
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(TraxServerSvc)
When win32event.WaitForSingleObject(self.hWaitStop, 0) method returns zero , I need to quit the while loop to stop the service. But in the above case, since it blocks in accept , I need to make connection from client to completely stop service.
--
nambi
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: Python as Windows Service "Arulnambi Nandagoban" <a.nandagoban@traxens.com> - 2014-09-24 16:49 +0200
csiph-web