473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

[2.2.1]How To Gracefully Shutdown an XML-RPC Server

I'm reading source code, but I haven't found any examples of
how to simply shutdown my XML-RPC server. I've done some nice things
w/ it so far. I can upload and dload arbitrary files, remotely execute
sys commands, etc. But I now want to use this code in a production
project and essentially control a FreeBSD box from a MSOFT Access
DB application. But the only Python fn I haven't been able to coerce
into submission is sys.exit() !

Here's my server method:

def sys_Shutdown( self ):
# don't work as is....
sys.exit( 0 )
return 0

And here's what happens:

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "D:\PYTHON22\lib\xmlrpclib.py", line 821, in __call__
return self.__send(self.__name, args)
File "D:\PYTHON22\lib\xmlrpclib.py", line 975, in __request
verbose=self.__verbose
File "D:\PYTHON22\lib\xmlrpclib.py", line 853, in request
return self.parse_response(h.getfile())
File "D:\PYTHON22\lib\xmlrpclib.py", line 896, in parse_response
return u.close()
File "D:\PYTHON22\lib\xmlrpclib.py", line 571, in close
raise apply(Fault, (), self._stack[0])
Fault: <Fault 1: 'exceptions.SystemExit:0'>

This is really bugging me, since I built everything else on
my own. Any ideas ? Jet
Jul 18 '05 #1
4 4018
The Jetman:
I'm reading source code, but I haven't found any examples of
how to simply shutdown my XML-RPC server.


http://aspn.activestate.com/ASPN/Coo.../Recipe/114579

Or you can ungracefully use os._exit, like pulling the emergency
brake on a train.

Andrew
da***@dalkescientific.com
Jul 18 '05 #2
"Andrew Dalke" <ad****@mindspring.com> wrote in message news:<yx*****************@newsread4.news.pas.earth link.net>...
The Jetman:
I'm reading source code, but I haven't found any examples of
how to simply shutdown my XML-RPC server.


http://aspn.activestate.com/ASPN/Coo.../Recipe/114579

Or you can ungracefully use os._exit, like pulling the emergency
brake on a train.

Andrew
da***@dalkescientific.com


Andrew:

Thanx ! I *swear* I always spend at least a couple hours or so looking
for stuf like this on my own ! That's the single most frustrating part
about the Web (besides this idiotic W32.Swen virus/worm) ! No matter
how you compose a query, there's always something that you miss....

BTW, I haven't tried it, but I bet os._exit will fail just like
sys.exit(). Besides the reason for a graceful shutdown is more
than cosmetic, since a forced shutdown (like a Ctrl-C) may occasionally
leave the sockets allocated (which *has* happened.)

Later....Jet
Jul 18 '05 #3
The Jetman:
Thanx ! I *swear* I always spend at least a couple hours or so looking
for stuf like this on my own !
The Python Cookbook is an impressive collection of tidbits.
BTW, I haven't tried it, but I bet os._exit will fail just like
sys.exit().
Unlikely. sys.exit actually raises a Python exception,
SystemExit. This is caught by the XMLPRC server
and converted into a message for the client.

(And this a reason you shouldn't use "except:" in
your code. Though if you really need it, you should
consider
except SystemExit:
raise
except:
...
)

os._exit uses the C function '_exit' which does an exit
right away, without doing the normal cleanups that
exit(3C) does. It doesn't raise an exception and cannot
be overriden by other Python code. (Unless os._exit
was replaced.)
Besides the reason for a graceful shutdown is more
than cosmetic, since a forced shutdown (like a Ctrl-C) may occasionally
leave the sockets allocated (which *has* happened.)


Let me guess, you quit a server program then restarted
it only to get a "cannot rebind to port" error message?

Ctrl-C raises a KeyboardInterrupt exception and its
effect should be the same as SystemExit, except for a
couple very minor issues. It isn't the same as using
os._exit.

What you're seeing is a consequence of the code
not properly handling its network resources. Eg,
it could register an atexit handler which forces
shut all open sockets.

See
http://www.manualy.sk/sock-faq/unix-...html#time_wait
for a description of what's happening at the TCP level.

Even when that happens, it doesn't "leave the socket
[permanently] allocated" in the system level. If you
wait long enough, the system should release the port.

Andrew
da***@dalkescientific.com
Jul 18 '05 #4
"Andrew Dalke" <ad****@mindspring.com> wrote in message news:<yx*****************@newsread4.news.pas.earth link.net>...
The Jetman:
I'm reading source code, but I haven't found any examples of
how to simply shutdown my XML-RPC server.


http://aspn.activestate.com/ASPN/Coo.../Recipe/114579

Or you can ungracefully use os._exit, like pulling the emergency
brake on a train.

Andrew
da***@dalkescientific.com


Andrew:

Thanx ! I *swear* I always spend at least a couple hours or so looking
for stuf like this on my own ! That's the single most frustrating part
about the Web (besides this idiotic W32.Swen virus/worm) ! No matter
how you compose a query, there's always something that you miss....

BTW, I haven't tried it, but I bet os._exit will fail just like
sys.exit(). Besides the reason for a graceful shutdown is more
than cosmetic, since a forced shutdown (like a Ctrl-C) may occasionally
leave the sockets allocated (which *has* happened.)

Later....Jet
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SamuelSudhakarJ | last post by:
Dear Pals, I am creating a XML document through this code: Imports System Imports System.IO Imports System.Xml Imports System.Text Module Module1 Sub Main()
1
by: telescient telescient via .NET 247 | last post by:
(Type your message here) How to transform xml variable to xsl file using asp.net using vb.net -------------------------------- From: telescient telescient ----------------------- Posted by a...
0
by: nithyasri | last post by:
How to Parse Xml schema using .NET and get an object model? I need to parse an Xml schema and display it as a tree structure in dot net. How do i do it? Any help will be appreciated.
3
by: Dhananjay | last post by:
hello everyone my problem is how to convert xml into html .I am getting this xml from a website. i am using C#.net , asp.net (VS 2005).if u have any idea or any type of resources which matches my...
0
by: ramakrishnareddy | last post by:
Hello , I am new in Cake PHP , i have small problem , How to use XML Parer Input as a String in Cake PHP , i was tried xml file as input in our file it's working fine i want to pass...
1
by: bylabylamo | last post by:
anyone please give me an idea of how to convert xml to rss. also please give me some sample xml files that are converted to rss.
1
by: snitu | last post by:
Hello I have a problem in creation of xml file in this mathematics expr. x=(-B±√( B²-4AC))/(2A) Can anyone tell me how to write xml and xslt of this expression. Thanks.
2
by: karansingla | last post by:
hi.. how to validate XML with its XSD ........... in tdom parser there is package tnc avaliable . with this i can validate only XML and its DTD not XSD ................is there any other library...
0
by: liuhengyi | last post by:
Hi, I also have a question when using VS 2008 to edit the xml file. In my xml file, I used schemaLocation attribute to specify the xsd. If I put the xsd in our internal sharepoint site such as:...
6
by: =?Utf-8?B?RGF2aWRN?= | last post by:
Hello, I have an XML file generated from a third party application that I would like to parse. Ideally, I plan on having a windows service setup to scan various folders for XML files and parse the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.