#!/bin/python3 import pyudev import locale import threading import subprocess # I tested this script with 1 vCPU, I probably don't work with more vCPUs # # Anaconda uses en_US.utf8 locale # # __wcsmbs_load_conv is called from pyudev only when multibyte characters are used locale.setlocale(locale.LC_ALL, 'en_US.utf8') def th1(): context = pyudev.Context() # this thread must be preempted when will be in the middle # of __wcsmbs_load_conv. We need to burn some cpu time in the loop below. # 300 is magic number which works on my VM, it can be different in another setup for i in range(0,300): print(i) return [d for d in context.list_devices(subsystem=u"block")] def th2(): print("th2") # we assume that hwclock is not in the first directory in $PATH p = subprocess.Popen(['hwclock', '--version']) p.wait() thread1 = threading.Thread(target=th1) thread2 = threading.Thread(target=th2) thread1.start() thread2.start() thread1.join() thread2.join()