Hi, I'm getting an error "Error running WSGI application: TypeError: 'module' object is not callable." I have read other posts on this topic and implemented the advice but it's not working for me, and I'm also observing additional unexpected behavior.
My web configuration is set up like this: Source code: /home/viralpersistence/bluesky-feed-generator Working directory: /home/viralpersistence/bluesky-feed-generator WSGI configuration file: /var/www/viralpersistence_pythonanywhere_com_wsgi.py
The app variable is defined in /home/viralpersistence/bluesky-feed-generator/server/app.py.
The code in the WSGI file:
import sys
from dotenv import load_dotenv
from server.logger import logger
load_dotenv()
logger.info(sys.path)
path = '/home/viralpersistence/bluesky-feed-generator/'
if path not in sys.path:
sys.path.insert(0, path)
logger.info(sys.path)
from server import app as application
The weird behavior: I have log statements in server/app.py that are written to the log as expected, and running /var/www/viralpersistence_pythonanywhere_com_wsgi.py drops me into the python terminal as I believe it's supposed to. But when I actually try to access the site, the error is written to the log. Within server/app.py, I'm starting a thread that listens to a firehose of social media content:
import sys
import signal
import threading
from server import config
from server import data_stream
from server.logger import logger
logger.info("0")
from flask import Flask, jsonify, request
logger.info("1")
from server.algos import algos
logger.info("2")
from server.data_filter import operations_callback
logger.info("3")
app = Flask(__name__)
try:
stream_stop_event = threading.Event()
stream_thread = threading.Thread(
target=data_stream.run, args=(config.SERVICE_DID, operations_callback, stream_stop_event,)
)
stream_thread.start()
logger.info("4")
except:
logger.info("failed")
"0" through "4" are written to the log as expected. However, I have an additional call to the logger at the beginning of operations_callback that is not written to the log, presumably because it's a callback function although running app.py on my local machine immediately writes it. I have a free account and I'm wondering if it's failing because I can't use more than one thread, although it seems the paid accounts come with web workers, which appear to be something different.
My code is forked from this repo and is basically the same at this point, if that helps. Thanks so much in advance!