I have a python script that posting content to a Wordpress site via the wordpress_xmlrpc
library.
This is a piece of my code that sends captured contents to the web site:
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import GetPosts, NewPost
from wordpress_xmlrpc.methods.users import GetUserInfo
from wordpress_xmlrpc.methods.posts import EditPost
wp = Client("http://example.com/xmlrpc.php", '#####', '######')
wp.call(GetPosts())
wp.call(GetUserInfo())
post = WordPressPost()
post.title = My_title
post.content = post_content_var
post.terms_names = {'category': ['something']}
post.post_status = "publish"
post.comment_status = "open"
post.id = wp.call(NewPost(post))
print(">>>> The Post ID: ", post.id)
My problem is with the server side. Sometimes the web server will be out of resources and responds with a HTTP 508 error status. When the xml-rpc code is trying to send a post, but the server is not available then the post is lost.
Is there any way to detect 508 errors and handle these?