Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:18:28+00:00 2026-06-02T11:18:28+00:00

I can’t seem to get my @postfork functions to run… 1 import uwsgi 2

  • 0

I can’t seem to get my @postfork functions to run…

  1 import uwsgi
  2 from uwsgidecorators import *
  3 from gevent import monkey; monkey.patch_all()
  4 import sys
  5 import umysql
  6 import time
  7 
  8 DB_HOST = 'stage.masked.com'
  9 DB_PORT = 3306
 10 DB_USER = 'masked'
 11 DB_PASSWD = 'masked'
 12 DB_DB = 'masked'
 13 
 14 mysql_conn = None
 15 
 16 @postfork
 17 def zebra():
 18     print "I AM ZEBRA"
 19     raise
 20     
 21 @postfork
 22 def setup_pool():
 23     global mysql_conn
 24     mysql_conn = umysql.Connection()
 25     print "HIII" 
 26     sys.stderr.write(str(mysql_conn.is_connected()))
 27     mysql_conn.connect (DB_HOST, DB_PORT, DB_USER, DB_PASSWD, DB_DB)
 28     sys.stderr.write(str(mysql_conn.is_connected()))
 29     
 30 def application(env, start_response):
 31     print "HALLO"

When I start uwsgi, I get nothing until I hit the route (defined in nginx that calls this py app). Here’s how I start uwsgi:

# uwsgi --socket=/tmp/uwsgi_server.sock --master --processes=2 --listen=4096 --disable-logging --loop gevent --async 128 --uid=www-data --gid=www-data --vhost
*** Starting uWSGI 1.1.2 (64bit) on [Thu Apr 19 23:55:32 2012] ***
compiled with version: 4.6.1 on 18 April 2012 20:10:46
current working directory: /ebs/py
detected binary path: /usr/local/bin/uwsgi
setgid() to 33
setuid() to 33
your memory page size is 4096 bytes
detected max file descriptor number: 1024
async fd table size: 1024
allocated 130048 bytes (127 KB) for 128 cores per worker.
VirtualHosting mode enabled.
lock engine: pthread mutexes
uwsgi socket 0 bound to UNIX address /tmp/uwsgi_server.sock fd 3
Python version: 2.7.2+ (default, Oct  4 2011, 20:41:12)  [GCC 4.6.1]
Python main interpreter initialized at 0xbb9ad0
your server socket listen backlog is limited to 4096 connections
*** Operational MODE: preforking+async ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 3340)
spawned uWSGI worker 1 (pid: 3341, cores: 128)
spawned uWSGI worker 2 (pid: 3342, cores: 128)
*** running gevent loop engine [addr:0x451080] ***
WSGI app 0 (mountpoint='masked.com|') ready in 0 seconds on interpreter 0xbb9ad0 pid: 3342

When I hit the route, I get:

HALLO

How can I get my @postfork functions to run? My end goal is to get connection pooling in the application function.

Thanks!

UPDATE: If I swap out –vhost for –wsgi-file=server.py, it works as expected.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:18:30+00:00Added an answer on June 2, 2026 at 11:18 am

    there is no catchable fork() if you use dynamic apps (the fork() all happen before app loading)

    You can move postfork hooks in a .py file you can import on server startup with

    –import modulename/filename

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can MOSS integrate and get user profiles from multiple Active Directory and/or LDAP stores?
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Can I run this in a Windows command prompt like I can run it
Can a Visual Studio 2008 custom tool be passed additional parameters from the custom
Can anyone tell me what i am doing wrong? I am trying to get
Can we put functions to determine the condition for our list comprehensions. Here is
Does anyone know how can I replace this 2 symbol below from the string
Can i get the source code for a WAMP stack installer somewhere? Any help
Can a LINQ enabled app run on a machine that only has the .NET
can anyone help me in trying to check whether JavaScript is enabled in client

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.