python-wordpress-xmlrpc client hangs when creating a new post
workvista opened this issue · comments
I am trying to add a custom post type via xmlrpc:
wp = Client(url, username, password)
post = WordPressPost()
post.post_type = 'job'
post.custom_fields = []
post.title = job.job_title
post.custom_fields.append({
'key' : 'job_title',
'value': job.job_title
})
post.custom_fields.append({
'key' : 'number_of_posts',
'value': job.num_posts
})
post.custom_fields.append({
'key' : 'organization',
'value': job.organization
})
post.custom_fields.append({
'key' : 'job_links',
'value': ','.join(job.organization_links)
})
post.custom_fields.append({
'key' : 'description',
'value': job.job_description
})
wp_post_id = wp.call(NewPost(post))
The last line hangs and does not return.
Some observations: 1. When I set fewer custom fields, it successfully creates the post. 2. This works on my local OSX but doesn't work on ubuntu 12.04 3. Other wordpress xmlrpc methods like GetPosts work fine.
Please advise. Thanks in advance
Here's the thread dump of the hanged program:
File "/root/workvista/scripts/wp_post_job.py", line 206, in post_job
wp_post_id = WordPress.wp.call(NewPost(post))
File "/root/workvista/scripts/workvista_env/lib/python2.7/site-packages/wordpress_xmlrpc/base.py", line 37, in call
raw_result = server_method(*args)
File "/usr/local/lib/python2.7/xmlrpclib.py", line 1240, in __call__
return self.__send(self.__name, args)
File "/usr/local/lib/python2.7/xmlrpclib.py", line 1599, in __request
verbose=self.__verbose
File "/usr/local/lib/python2.7/xmlrpclib.py", line 1280, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/local/lib/python2.7/xmlrpclib.py", line 1310, in single_request
response = h.getresponse(buffering=True)
File "/usr/local/lib/python2.7/httplib.py", line 1132, in getresponse
response.begin()
File "/usr/local/lib/python2.7/httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python2.7/httplib.py", line 409, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/local/lib/python2.7/socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
Looks like it hangs at the time of receiving the response.
Maybe this is helpful.
when i try using curl command to post the same xml, It times out :
* About to connect() to workvista.in port 80 (#0)
* Trying 198.71.233.11... connected
> POST /xmlrpc.php HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: workvista.in
> Accept: */*
> Content-Type: text/xml
> Cache-Control: no-cache
> Postman-Token: fae643e9-3448-f0db-33bb-cae4d0499cae
> Content-Length: 8606
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 408 Request Timeout
< Date: Thu, 07 Jul 2016 06:55:57 GMT
< Server: Apache
< Content-Length: 221
< Content-Type: text/html; charset=iso-8859-1
< X-Port: port_10876
* HTTP error before end of send, stop sending
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>408 Request Timeout</title>
</head><body>
<h1>Request Timeout</h1>
<p>Server timeout waiting for the HTTP request from the client.</p>
</body></html>
* Closing connection #0
How do I fix this ?
if it's only a time out issue, then you can increase execution time on server