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

os.system() not returning

I have a Python program that does the following (pseudo-code):

while True:
is_downloading = True
use ftplib to download any new files from a server
is_downloading = False

To deal with intermittent connectivity/failures (this is running on a
mobile device), /etc/ppp/ip-up.local (a program that is run whenever
Internet connectivity is established) issues SIGUSR1 to the python
process, which handles it as such:

def handle_sigusr1(sig, bt):
global is_downloading, debug
if debug: print 'got SIGUSR1'; sys.stdout.flush()
if is_downloading:
args = ['python'] + sys.argv
if debug: print 'spawning', args; sys.stdout.flush()
pid = os.spawnvp(os.P_NOWAIT, 'python', args)
if debug: print 'pid', pid; sys.stdout.flush()
os.kill(os.getpid(), SIGTERM)
signal(SIGUSR1, handle_sigusr1)

(I start a new process since I didn't want to get into the business of
killing threads.)

However, os.system() occasionally does not return. It's just:

os.system('make -C ' + localpath + ' -f ' + makefiles[-1])
if debug: print 'sleeping'

and the stdout log always ends in "make: Leaving directory `/dldir'"
(make finishes). The python process is still running, but doesn't
respond to SIGUSR1, so perhaps it's still in the syscall. (SIGTERM
kills it, though; no SIGKILL needed.)

I separately tested that (a) python can be interrupted by SIGUSR1
while in blocking socket IO, and (b) SIGUSR1 doesn't screw up python
while in a os.system('make') (the signal gets handled after the call

Has anybody seen this kind of behavior, or might know what's going on?
Thanks in advance for any help.

FWIW, here is other info:

root@soekris4801:~$ uname -a
Linux soekris4801 2.6.20-soekris #2 Sun Nov 4 19:07:00 EST 2007 i586 unknown
root@soekris4801:~$ python -V
Python 2.5.1

Here are the commands the Makefile executes (repeatedly) - all
standard bash/command-line tools:

make: Entering directory `/dldir'
ls -1 /dldir/setup*.bash | tail -1 | xargs bash -x
+ set -o errexit
+ set -o nounset
+ mkdir -p /tftproot/
++ ls -1 /dldir/iii-03.tgz
++ sed 's/.*iii-\([0-9]*\)\.tgz.*/\1/'
++ tail -1
+ avail=03
++ cat /tftproot/iii-version
+ installed=03
+ '[' -z 03 ']'
+ (( installed < avail ))
make: Leaving directory `/dldir'
Nov 14 '07 #1
0 1058

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

Similar topics

by: Juan Galdeano | last post by:
Hi, I'm working on an ONIX project and when I try to validate or read XML files C# gives me this exception: System.IndexOutOfRangeException at System.Xml.XmlScanner.ScanDtdContent() at...
by: Nathan Sokalski | last post by:
I am using a System.IO.StreamReader to read a text file that was created with Notepad. It is returning everything except the single quotes (at least that is the only thing I have noticed it is not...
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
by: sandy | last post by:
I have a AxWebBrowser class. I wish to locate a specific element in its HTMLDocument which has a specific 'style'. I use the following code to access the element with the specific style:- ...
by: Mark Rae | last post by:
Hi, I'm in the process of updating an ASP.NET v1.1 web app to v2. The app uses ActiveDirectory a great deal, and I'm trying to use the new System.Collections.Generic namespace where possible,...
by: Nathan Sokalski | last post by:
I have an ASP.NET application which displays the directories & files in a specified directory on the server. I use the System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() to...
by: pauldepstein | last post by:
Below is posted from a link for Stanford students in computer science. QUOTE BEGINS HERE Because of the risk of misuse, some experts recommend never returning a reference from a function or...
by: nido | last post by:
Please i need the LIBRARY MANAGEMENT SYSTEM You have to design a library management system which will keep record of · All Books · Borrowers
by: =?Utf-8?B?QW50b25pbyBPJydOZWFs?= | last post by:
We changed a username in AD. The user now logs on to a computer on our network using the new username without any problems. They can not logon using the old username. However, when they access a...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.