fromuwsgiconf.runtime.mulesimportMulefromuwsgiconf.runtime.schedulingimportregister_timer# Let's print 'tick' every second in background.# Background processing is handled by mules (note `mules=1` in PythonSection.bootstrap() above).@register_timer(1,target=Mule(1))deftimer_1():print('tick')
Note
There is much more than just background processing. See Runtime documentation section.
fromuwsgiconf.configimportconfigure_uwsgifromuwsgiconf.presets.niceimportPythonSectiondefget_configurations():"""This should return one or more Section or Configuration objects. In such a way you can configure more than one uWSGI instance in the same place. """my_app_dir='/home/idle/myapp/'section=PythonSection(# Reload uWSGI when this file is updated.touch_reload=__file__,params_python=dict(# Let's add something to Python path.search_path='/opt/apps_shared/',),wsgi_module=f'{my_app_dir}wsgi.py',# We'll redirect logs into a file.log_into=f'{my_app_dir}app.log',# If your uWSGI has no basic plugins embedded# (i.e. not from PyPI) you can give uwsgiconf a hint:embedded_plugins=False,).networking.register_socket(# Make our app available at all ipv6 interfaces on port 8030PythonSection.networking.sockets.http('[::]:8030'))returnsectionconfigure_uwsgi(get_configurations)