Sam
Sam

Reputation: 23

uWSGI installed, but not being imported in Python

Using Python 3.5.2 on Ubuntu 16.04.5, with uwsgi 2.0.17.1(latest stable) installed. I am currently trying to write simple websocket ping-pong server with module flask-uwsgi-websocket. For graceful exit(which is required for further development, since this project won't end up ping-ponging each other), I've googled and found that I have to import uwsgi module and hook my func. Python's built-in signal method or onexit method didn't worked for me.

This is the point where problem occurs. I can run my program via uwsgi, with any options, also with .ini file, but cannot import uwsgi module in Python. There IS uWSGI module in python packages list(shown in PyCharm). I've tried reinstalling it, by building it and using pip, but the result is same.

What should I do to import uwsgi module in my script?

Upvotes: 1

Views: 1046

Answers (1)

vishes_shell
vishes_shell

Reputation: 23504

You case is described in documentation Python Module

The uWSGI server automagically adds a uwsgi module into your Python apps.

This is useful for configuring the uWSGI server, use its internal functions and get statistics. Also useful for detecting whether you’re actually running under uWSGI; if you attempt to import uwsgi and receive an ImportError you’re not running under uWSGI.

So that means that you will able to import uwsgi only when you run it via uwsgi.

Upvotes: 1

Related Questions