Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

concurrency/multithreaded XMLRPC problem: raise CannotSendRequest()

By
Vlad Janicek
on 10/4/13, 11:16 PM 3,069 views

Hey there:

I have been looking for a solution to this problem everywhere and it may be that I'm not asking the right questions. It may be simple, maybe too simple...

I have no problems every time I try to access records through XMLRPC, but if I get two requests at the same time, OpenERP crashes.

I have been testing concurrency and threads this way:

===
try:
    print 'Starting Threads...'
    thread.start_new_thread(get_prods, ('Thead 1', 10))
    thread.start_new_thread(get_partners, ('Thread 2', 10))
except:
  code code code.. etc
====

and this is what I get:

  File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1294, in single_request
    response = h.getresponse(buffering=True)
  File "/usr/lib/python2.7/httplib.py", line 1033, in getresponse
    raise ResponseNotReady()
httplib.ResponseNotReady

and...

  File "/usr/lib/python2.7/xmlrpclib.py", line 1289, in single_request
    self.send_request(h, handler, request_body)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1391, in send_request
    connection.putrequest("POST", handler, skip_accept_encoding=True)
  File "/usr/lib/python2.7/httplib.py", line 871, in putrequest
    raise CannotSendRequest()
httplib.CannotSendRequest

But if I do a time.sleep(1) between both threads, they all work perfectly. The functions executed by the threads are simple XMLRP calls to get products and partners... nothing more.

I know this may be a concurrency issue. I even started the server with --workers=N without any success...

Any ideas?? Thanks!!

0
Vlad Janicek
On 10/7/13, 8:49 PM

My bad... it turns out that I was recycling the same XMLRPC object for the same function.

I need to create a new object for each connection. As soon as I did, it worked!

Thanks :)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/4/13, 11:16 PM
Seen: 3069 times
Last updated: 3/16/15, 8:10 AM