@BetterAuto
You have not enough memory
Did you tested this after "fresh" reboot without any other your code?
I do not like when libs import whole units
e.g. import math can eat near to whole memory
but better is to do e.g.from math import sin,cos,pi

You can try to modify imports used in urllib - and you will see if it solve your problem