OCA / odoorpc

Python module to pilot your Odoo servers through JSON-RPC.
http://pythonhosted.org/OdooRPC/
GNU Lesser General Public License v3.0
237 stars 125 forks source link

odoo.db.drop - InterfaceError: connection already closed #43

Closed ETSJustin closed 5 years ago

ETSJustin commented 5 years ago

I have a curious problem when using odoo.db.drop on the last (large) Odoo database.

If I attempt to use odoorpc to drop the last remaining database on an Odoo server I get back the following error (even though the database is actually dropped):

Traceback (most recent call last): File "./db_delete.py", line 11, in f = odoo.db.drop('xxxxx', 'test') File "/usr/local/lib/python2.7/dist-packages/odoorpc/db.py", line 227, in drop 'args': [password, db]}) File "/usr/local/lib/python2.7/dist-packages/odoorpc/odoo.py", line 281, in json data = self._connector.proxy_json(url, params) File "/usr/local/lib/python2.7/dist-packages/odoorpc/rpc/jsonrpclib.py", line 124, in call response = self._opener.open(request, timeout=self._timeout) File "/usr/lib/python2.7/urllib2.py", line 435, in open response = meth(req, response) File "/usr/lib/python2.7/urllib2.py", line 548, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python2.7/urllib2.py", line 473, in error return self._call_chain(args) File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain result = func(args) File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 500: INTERNAL SERVER ERROR

Looking at the Odoo server log I see:

2019-03-12 14:11:14,472 233378 DEBUG None odoo.http.rpc.response: jsonrpc: None drop: time:1.758s mem: 392844k -> 392844k (diff: 0k), True 2019-03-12 14:11:14,519 233378 INFO None werkzeug: 127.0.0.1 - - [12/Mar/2019 14:11:14] "POST /jsonrpc HTTP/1.0" 500 - 2019-03-12 14:11:14,561 233378 ERROR None werkzeug: Error on request: Traceback (most recent call last): File "/home/odoo/odoo-10/lib/python2.7/site-packages/werkzeug/serving.py", line 193, in run_wsgi execute(self.server.app) File "/home/odoo/odoo-10/lib/python2.7/site-packages/werkzeug/serving.py", line 181, in execute application_iter = app(environ, start_response) File "/home/odoo/odoo-10/odoo/odoo/service/wsgi_server.py", line 184, in application return werkzeug.contrib.fixers.ProxyFix(application_unproxied)(environ, start_response) File "/home/odoo/odoo-10/lib/python2.7/site-packages/werkzeug/contrib/fixers.py", line 152, in call return self.app(environ, start_response) File "/home/odoo/odoo-10/odoo/odoo/service/wsgi_server.py", line 172, in application_unproxied result = handler(environ, start_response) File "/home/odoo/odoo-10/odoo/odoo/http.py", line 1326, in call return self.dispatch(environ, start_response) File "/home/odoo/odoo-10/odoo/odoo/http.py", line 1300, in call return self.app(environ, start_wrapped) File "/home/odoo/odoo-10/lib/python2.7/site-packages/werkzeug/wsgi.py", line 599, in call return self.app(environ, start_response) File "/home/odoo/odoo-10/odoo/odoo/http.py", line 1504, in dispatch response = self.get_response(httprequest, result, explicit_session) File "/home/odoo/odoo-10/odoo/odoo/http.py", line 279, in exit self._cr.commit() File "/home/odoo/odoo-10/odoo/odoo/sql_db.py", line 154, in wrapper return f(self, *args, **kwargs) File "/home/odoo/odoo-10/odoo/odoo/sql_db.py", line 376, in commit result = self._cnx.commit() InterfaceError: connection already closed

I have tried a few permutations of drop and it appears to only throw this error if the dropped database is the last remaining AND it is a largish database. Otherwise, the drop command completes without error.

I have, as a workaround, decided to silently consume this error and to independently verify that the database has been dropped, so this issue is not currently holding me up.

sebalix commented 5 years ago

@ETSJustin Hi, Can you tell me which version of OdooRPC you are using? Did you login on the db (with odoo.login) before dropping it? It may be not related, but I made a fix few days ago related to db.drop to force the logout if a session is opened on the db to drop (not released yet): https://github.com/OCA/odoorpc/pull/42 , feel free to test the master branch.

ETSJustin commented 5 years ago

Hi @sebalix

I am using OdooRPC 0.7.0 (sorry for neglecting to mention this earlier).

Nope, the affected script does not login to Odoo before the drop, though it is more that likely that the account is logged on on a browser somewhere.

If I can work out how to run against the master branch I will give it a go!

Thanks

sebalix commented 5 years ago

@ETSJustin to install the master branch, you can do that:

$ pip install git+https://github.com/OCA/odoorpc.git@master --upgrade [--user]

pedrobaeza commented 5 years ago

Closing as no more answers.