Skip to content

Instantly share code, notes, and snippets.

@Lothiraldan
Created June 14, 2016 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lothiraldan/218f0b84040e3bc0f8f1243884d838c6 to your computer and use it in GitHub Desktop.
Save Lothiraldan/218f0b84040e3bc0f8f1243884d838c6 to your computer and use it in GitHub Desktop.
Str encode in a thread
import time
import threading
def to_latin_1(event, value):
print(time.time(), "Before encode")
value.encode('latin-1', 'ignore')
print(time.time(), "After encode")
event.set()
print(time.time(), "Event set")
event = threading.Event()
thread = threading.Thread(target=to_latin_1, args=(event, u'42'))
thread.start()
event.wait(10)
import str_encode_thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment