2014-01-15 66 views
0

我是Python新手,我需要運行我的rails項目,它依賴於Python應用程序。 我使用Python與MySQL和嘗試運行的服務器,但它拋出一個錯誤:錯誤:MySQL_python:不支持線程之間的共享連接

17:41:41 affiliates.1 | /home/jayashri/homebrew/izea-exchange-master/affiliates/plugins/antipool.py:477: UserWarning: Warning: Your DBAPI module '<module 'MySQLdb' from '/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg/MySQLdb/__init__.pyc'>' does not support sharing connections between threads. 
17:41:41 affiliates.1 | "connections between threads." % str(dbapi)) 
17:41:41 affiliates.1 | [15/Jan/2014:17:41:41] ENGINE Listening for SIGHUP. 
17:41:41 affiliates.1 | [15/Jan/2014:17:41:41] ENGINE Listening for SIGTERM. 
17:41:41 affiliates.1 | [15/Jan/2014:17:41:41] ENGINE Listening for SIGUSR1. 
17:41:41 affiliates.1 | [15/Jan/2014:17:41:41] ENGINE Bus STARTING 
17:41:41 affiliates.1 | [15/Jan/2014:17:41:41] ENGINE PID 22407 written to './affiliates_dev.pid'. 
17:41:41 affiliates.1 | [15/Jan/2014:17:41:41] ENGINE Started monitor thread '_TimeoutMonitor'. 
17:41:41 affiliates.1 | [15/Jan/2014:17:41:41] ENGINE Started monitor thread 'Autoreloader'. 
17:41:42 lucre.1  | => Booting WEBrick 
17:41:42 lucre.1  | => Rails 2.3.15 application starting 

17:41:46 affiliates.1 | [15/Jan/2014:17:41:46] ENGINE Error in 'start' listener <bound method Server.start of <cherrypy._cpserver.Server object at 0x1470f50>> 
17:41:46 affiliates.1 | Traceback (most recent call last): 
17:41:46 affiliates.1 | File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.1.2-py2.7.egg/cherrypy/process/wspbus.py", line 147, in publish 
17:41:46 affiliates.1 |  output.append(listener(*args, **kwargs)) 
17:41:46 affiliates.1 | File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.1.2-py2.7.egg/cherrypy/_cpserver.py", line 90, in start 
17:41:46 affiliates.1 |  ServerAdapter.start(self) 
17:41:46 affiliates.1 | File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.1.2-py2.7.egg/cherrypy/process/servers.py", line 53, in start 
17:41:46 affiliates.1 |  wait_for_free_port(*self.bind_addr) 
17:41:46 affiliates.1 | File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.1.2-py2.7.egg/cherrypy/process/servers.py", line 251, in wait_for_free_port 
17:41:46 affiliates.1 |  raise IOError("Port %r not free on %r" % (port, host)) 
17:41:46 affiliates.1 | IOError: Port 7180 not free on '0.0.0.0' 
17:41:46 affiliates.1 | 
17:41:46 affiliates.1 | [15/Jan/2014:17:41:46] ENGINE Shutting down due to error in start listener: 
17:41:46 affiliates.1 | Traceback (most recent call last): 
17:41:46 affiliates.1 | File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.1.2-py2.7.egg/cherrypy/process/wspbus.py", line 184, in start 
+1

您指定的錯誤不是錯誤,而是警告。而實際的錯誤是'IOError:端口7180在'0.0.0.0''上不可用。您正嘗試多次綁定到相同的地址。 – twil

回答

0

twil是正確的 - 你需要一個不同的端口爲每個Python應用程序。如果你是在Linux上以root身份運行此命令(它會告訴你其他的Python應用程序都runninng)

ps -ef | grep python 

找到這些應用程序正在運行的端口,並選擇不同的端口。您可以使用其他非Python應用程序使用該端口。在這種情況下,你應該看看使用的端口是什麼?

https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-server-ports.html

希望這有助於!

+0

謝謝twil和安德魯這個答案有助於解決我的問題,我已經在不同的端口上運行python。 – user3197966

+0

酷 - 歡迎來到StackOverflow!如果我的答案幫助您解決了問題,請將其標記爲正確答案。這將幫助其他人找到解決方案。 –