The Artima Developer Community
Sponsored Link

Python Buzz Forum
Invoking qmail-inject from Python on FreeBSD without hanging

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Phillip Pearson

Posts: 1083
Nickname: myelin
Registered: Aug, 2003

Phillip Pearson is a Python hacker from New Zealand
Invoking qmail-inject from Python on FreeBSD without hanging Posted: Oct 6, 2003 9:45 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Phillip Pearson.
Original Post: Invoking qmail-inject from Python on FreeBSD without hanging
Feed Title: Second p0st
Feed URL: http://www.myelin.co.nz/post/rss.xml
Feed Description: Tech notes and web hackery from the guy that brought you bzero, Python Community Server, the Blogging Ecosystem and the Internet Topic Exchange
Latest Python Buzz Posts
Latest Python Buzz Posts by Phillip Pearson
Latest Posts From Second p0st

Advertisement
I recently ran into some odd behaviour when trying to call qmail's qmail-inject tool from a Python script with os.popen. The script was hanging when I tried to close the file.

It turns out that this is an old bug that is apparently qmail's problem. That doesn't help me, but the workaround in this message does: use popen2.popen2 instead.

Practically, that means that instead of this:

    f = os.popen('/var/qmail/bin/qmail-inject %s' % address, 'w')

You want to say:

    f = popen2.popen2('/var/qmail/bin/qmail-inject %s' % address)[1]

... and your script will then run fine.

My application was the e-mail responder script that I use to edit Crash. Previously I was just getting the script to time out like this:

import signal

def timed_out(sig, f):
    print "timed out!"
    os.exit(99)

signal.signal(signal.SIG_ALRM, timed_out)
signal.alarm(60)


I've left that bit in - it serves to kill the script when weblogs.com stops responding. But now, at least, I don't always get a failure response 60 seconds after the success response.

Comment

Read: Invoking qmail-inject from Python on FreeBSD without hanging

Topic: mod_python introduction Previous Topic   Next Topic Topic: What real errors does pychecker catch?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use