Using Python decorators to retry request

You can use a decorator like this and handle your own exception. def retry(times, exceptions): “”” Retry Decorator Retries the wrapped function/method `times` times if the exceptions listed in “exceptions“ are thrown :param times: The number of times to repeat the wrapped function/method :type times: Int :param Exceptions: Lists of exceptions that trigger a retry … Read more

Remove whitespaces in XML string

The easiest solution is probably using lxml, where you can set a parser option to ignore white space between elements: >>> from lxml import etree >>> parser = etree.XMLParser(remove_blank_text=True) >>> xml_str=””‘<root> >>> <head></head> >>> <content></content> >>> </root>”’ >>> elem = etree.XML(xml_str, parser=parser) >>> print etree.tostring(elem) <root><head/><content/></root> This will probably be enough for your needs, but … Read more

Python in docker – RuntimeError: can’t start new thread

Solution to this problem was to upgrade docker from version 18.06.1-ce to 20.10.7. Why? This is because the default seccomp profile of Docker 20.10.9 is not adjusted to support the clone() syscall wrapper of glibc 2.34 adopted in Ubuntu 21.10 and Fedora 35. Source: ubuntu:21.10 and fedora:35 do not work on the latest Docker (20.10.9)

File not found.