473,395 Members | 1,442 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,395 software developers and data experts.

incompatible exit values between python 2.4 and 2.5

I have a small C program that restarts a python based server
application if the exit value of the
system("python -m pythonscript arg1 arg2 ...")
is greater than 127 (using WEXITSTATUS on the result of system(..))
If the server really needs to stop I exit with
sys.exit(0)
but if I just want it to restart (to reread all modules) I can do
sys.exit(128)

With python 2.4, if pythonscript.py could not be found, the exit value
would be 2 and if there was some syntax error, or other exception
raised, the exit value would be 1.

While trying this out with Python 2.5 I found that the exit value on
error is always 255, so I have to change my script (not a big deal).
However two questions came up while finding out what was
the difference:

1) is this change of behaviour documented somewhere and did I miss
that, or has this not been documented (yet)
2) Is there a build-in way to set the exit value for Python in case an
exception is raised that is uncaught and causes python to terminate? (I
have now implemented something using
try:
...
except ImportError, comment:
sys.exit(2)
except:
sys.exit(1)
but I still have to figure out how to print the stacktrace before
exiting with specific values.)

Regards
Anthon

Sep 18 '06 #1
2 1812
1) is this change of behaviour documented somewhere and did I miss
that, or has this not been documented (yet)
2) Is there a build-in way to set the exit value for Python in case an
exception is raised that is uncaught and causes python to terminate? (I
have now implemented something using
try:
...
except ImportError, comment:
sys.exit(2)
except:
sys.exit(1)
but I still have to figure out how to print the stacktrace before
exiting with specific values.)
For the latter, take a look at

sys.exc_info()
Diez
Sep 18 '06 #2

Diez B. Roggisch wrote:
1) is this change of behaviour documented somewhere and did I miss
that, or has this not been documented (yet)
2) Is there a build-in way to set the exit value for Python in case an
exception is raised that is uncaught and causes python to terminate? (I
have now implemented something using
try:
...
except ImportError, comment:
sys.exit(2)
except:
sys.exit(1)
but I still have to figure out how to print the stacktrace before
exiting with specific values.)

For the latter, take a look at

sys.exc_info()
or perhaps the traceback module ...

Cheers,
John

Sep 18 '06 #3

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

Similar topics

0
by: Cj B | last post by:
Hello, While trying to compile PHP with Oracle Support (--with-oci8), I get the following error: /usr/local/sparc-sun-solaris2.8/bin/ld: skipping incompatible...
1
by: Mark McEahern | last post by:
Is there a straightforward way to get the exit code from a windows process? I want to write a script that runs a bunch of .sql files against SQL Server using osql. I want it to stop if there's...
8
by: Mike Maxwell | last post by:
<vent> I see there has been traffic over the years on this gripe, so just let me vent my frustration, and add another reason why 'exit' (or possibly exit() or quit() or halt() or some such) should...
2
by: Ishwar Rattan | last post by:
Here is a piece code (according to blurb on os.wait, the lower order 7 bits of exit status of process should contain the signal number of signal that terminated the process..) and signal number...
2
by: Jean | last post by:
Hello everyone, I was having the following problem with a query, and after failing to find a similar solution on these newsgroups I decided to post here. I am quite new to Access, so would...
7
by: Brian Stubblefield | last post by:
Dear clc members, I am new to C and am posting several messages concerning a large C program that I am debugging. I am encountering a "incompatible types in assignment" warning for the...
2
by: Dennis Schulz | last post by:
Hi all, the following programm is supposed to check for login and password with inbuilt linux functions. in line 57 and 64 there are erorrs: incompatible types in asignment. whats wrong with...
2
by: sunyao | last post by:
Hi Friend, I write a linux shell script to call a python script inside. But I got a wrong exit code from Python exit code. The linux shell script as follows; #!/bin/bash MyPython.py exit $? ...
4
by: Quill_Patricia | last post by:
I have a Python script which is used to load data into a database. Up to now this script has been run by customers from the Windows command prompt using "python edg_loader.pyc". Any error messages...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.