Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception in Worker Process When Running "heroku local"

I recently acquired a project that I am using heroku to build. I want to run it locally however I am running into trouble and I don't have much experience with Heroku. This is what I get when I try to run heroku local.

Mac Terminal Command

kaMacintosh:zddev ka$ heroku local
forego | starting web.1 on port 5000
web.1  | [2015-12-26 15:12:43 -0500] [1741] [INFO] Starting gunicorn 19.4.1
web.1  | [2015-12-26 15:12:43 -0500] [1741] [INFO] Listening at: http://0.0.0.0:5000 (1741)
web.1  | [2015-12-26 15:12:43 -0500] [1741] [INFO] Using worker: sync
web.1  | [2015-12-26 15:12:43 -0500] [1744] [INFO] Booting worker with pid: 1744
web.1  | [2015-12-26 15:12:43 -0500] [1744] [ERROR] Exception in worker process:
web.1  | zd/main.py", line 6, in <module>
web.1  | ka/Documents/zdenvs/zddev/main.py", line 6, in <module>
web.1  | [2015-12-26 15:12:43 -0500] [1744] [INFO] Worker exiting (pid: 1744)
web.1  | Traceback (most recent call last):
web.1  |     sys.exit(run())
web.1  |   File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
web.1  |     super(Application, self).run()
web.1  |   File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
web.1  |     Arbiter(self).run()
web.1  |   File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 179, in run
web.1  |     self.manage_workers()
web.1  |   File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 482, in manage_workers
web.1  |     self.spawn_workers()
web.1  |   File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 549, in spawn_workers
web.1  |     time.sleep(0.1 * random.random())
web.1  |   File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 219, in handle_chld
web.1  |     self.reap_workers()
web.1  |   File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 464, in reap_workers
web.1  |     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
web.1  | gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

Procfile

web: gunicorn main:app --log-file=-

It appears line 6 is the issue which is mysql.connector, here are the first several lines to main.py

main.py

import os
import sys
import json
import urllib
import custom
import mysql.connector
import datetime
import operator

from flask import Flask, jsonify
from flask import render_template
from flask import request, redirect, url_for
from mysql.connector import errorcode
application = Flask(__name__)
app = application

Any ideas as to what is causing the error or how to solve. Is it really mysql.connector causing the issue on line 6 in main.py? I am using Python 2.7.11.

Running gunicorn main:app on its own produces

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
    __import__(module)
  File "/Users/ka/Documents/zdenvs/zddev/main.py", line 6, in <module>
    import mysql.connector
ImportError: No module named mysql.connector
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
    __import__(module)
  File "/Users/ka/Documents/zdenvs/zddev/main.py", line 6, in <module>
    import mysql.connector
ImportError: No module named mysql.connector
[2016-01-04 15:34:18 -0500] [6225] [INFO] Worker exiting (pid: 6225)
Traceback (most recent call last):
  File "/usr/local/bin/gunicorn", line 11, in <module>
    sys.exit(run())
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 192, in run
    super(Application, self).run()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
    Arbiter(self).run()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 179, in run
    self.manage_workers()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 482, in manage_workers
    self.spawn_workers()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 549, in spawn_workers
    time.sleep(0.1 * random.random())
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 219, in handle_chld
    self.reap_workers()
  File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 464, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
like image 560
applecrusher Avatar asked Nov 08 '22 22:11

applecrusher


1 Answers

There was an issue with the mysql-connector-python library. It was abandoned midway through my project, so it was on installed on the heroku instance but not on my local machine. Instead I just replaced the this line in the requirements.txt file:

mysql-connector-python==2.0.4

with

https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.tar.gz
like image 90
applecrusher Avatar answered Nov 14 '22 23:11

applecrusher