0

I am new to coding and I have just written an app using Flask and Socket.io called Chatbox.

Here is the app: Github: Chatbox-2020

It runs smoothly on local, however, when I pushed it to Heroku, it keeps showing errors:

2020-05-26T11:01:02.401356+00:00 app[web.1]: [2020-05-26 11:01:02 +0000] [4] [INFO] Listening at: http://0.0.0.0:34980 (4)
2020-05-26T11:01:02.401471+00:00 app[web.1]: [2020-05-26 11:01:02 +0000] [4] [INFO] Using worker: sync
2020-05-26T11:01:02.406378+00:00 app[web.1]: [2020-05-26 11:01:02 +0000] [9] [INFO] Booting worker with pid: 9
2020-05-26T11:01:02.488374+00:00 app[web.1]: [2020-05-26 11:01:02 +0000] [10] [INFO] Booting worker with pid: 10
2020-05-26T11:01:03.881191+00:00 heroku[web.1]: State changed from starting to up
2020-05-26T11:01:03.868598+00:00 app[web.1]: PRINT INFO: CHANNEL
2020-05-26T11:01:03.868668+00:00 app[web.1]: NAME: General
2020-05-26T11:01:03.868719+00:00 app[web.1]: CREATOR: default
2020-05-26T11:01:03.868779+00:00 app[web.1]: MESSAGES: 0
2020-05-26T11:01:03.868830+00:00 app[web.1]: DEFAULT CHANNEL CREATED
2020-05-26T11:01:03.870458+00:00 app[web.1]: Failed to parse '' as an attribute name or function call.
2020-05-26T11:01:03.870490+00:00 app[web.1]: PRINT INFO: CHANNEL
2020-05-26T11:01:03.870495+00:00 app[web.1]: NAME: General
2020-05-26T11:01:03.870522+00:00 app[web.1]: CREATOR: default
2020-05-26T11:01:03.870527+00:00 app[web.1]: MESSAGES: 0
2020-05-26T11:01:03.870548+00:00 app[web.1]: DEFAULT CHANNEL CREATED
2020-05-26T11:01:03.870894+00:00 app[web.1]: [2020-05-26 11:01:03 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-05-26T11:01:03.872098+00:00 app[web.1]: Failed to parse '' as an attribute name or function call.
2020-05-26T11:01:03.872376+00:00 app[web.1]: [2020-05-26 11:01:03 +0000] [9] [INFO] Worker exiting (pid: 9)
2020-05-26T11:01:04.036138+00:00 app[web.1]: [2020-05-26 11:01:04 +0000] [4] [INFO] Shutting down: Master
2020-05-26T11:01:04.036243+00:00 app[web.1]: [2020-05-26 11:01:04 +0000] [4] [INFO] Reason: App failed to load.
2020-05-26T11:01:04.117169+00:00 heroku[web.1]: Process exited with status 4
2020-05-26T11:01:04.160505+00:00 heroku[web.1]: State changed from up to crashed

The error that keeps showing is "Failed to parse '' as an attribute name or function call." What exactly does it mean? Grateful if someone could help me figure out the problem!

gutwenger
  • 1
  • 1
  • Hello gutwenger, how exactly do you "push it to Heroku"? What file are you trying to serve (I assume it is the `chat.py`)? Your question misses some details. The error message is caused by some line in your code base. You are most familiar with your code, so try to narrow the error down e.g. by running an MVP first (so a minimal version of your chat w\o the logic). This way you may find the issue/can update your question to be more specific. To help you get started, somewhere after the `print('DEFAULT CHANNEL CREATED')` a parse error occurs. See what is executed next, remove/refactor & retry. – Kim May 26 '20 at 11:40
  • Some general remarks: kudos for using git from the start! Consider adding a `.gitignore` [file](https://git-scm.com/docs/gitignore), cause some files in your repo better remain on your local machine, namely __pycache__, .DS_Store and the venv folder. Sharing the [__pycache__](https://stackoverflow.com/questions/16869024/what-is-pycache) may cause issues of changes to your *.py files not having any effect, .DS_Store is a Mac OS specific file and the venv can be recreated from the requirements file. – Kim May 26 '20 at 11:54
  • There is a difference when you run a project with `python3 chat.py` (running the project locally) and `gunicorn chat:app` (running the project in production on Heroku). I don't know for certain but I can imagine that it won't execute the content of `if __name__ == '__main__'`. This may be intentional but for troubleshooting sake you should make development and deployment environment as similar as possible. Furthermore if you look into `chat.py` you are running `socketio.run(app)` before `app` and `socketio` was fully defined. You should put `if __name__ == '__main__'` at the end of your file – Tin Nguyen May 26 '20 at 12:37
  • If you look at the log it says `DEFAULT CHANNEL CREATED` twice. But in your code this line can only be printed once. This makes me believe your gunicorn is configured badly. – Tin Nguyen May 26 '20 at 12:39

0 Answers0