title: mulithreading environment and modules like pickle or json
body: <p>I am  using "import threading" and python 3.4. 
  Simple case, I have one main parent thread and one child thread. I need to save my dict to file from child thread. In thread function I have variable:</p>
  
  <pre><code>def thread_function(...)
      def save_to_file():
          this_thread_data.my_dict or nonlocal this_thread_data.my_dict 
          ... json or pickle
  
  
      this_thread_data = local()
      this_thread_data.my_dict = {...}
      ...
  </code></pre>
  
  <p>When I use pickle I get error</p>
  
  <pre><code>_pickle.PicklingError: Can't pickle &lt;class '_thread.lock'&gt;: attribute lookup lock on _thread failed
  </code></pre>
  
  <p>When I use json I get error</p>
  
  <pre><code>TypeError: &lt;threading.Event object at 0x7f49115a9588&gt; is not JSON serializable
  </code></pre>
  
  <p>Will pickle or json work in multithreading environment or I need to use something else instead?</p>
  
  <p>Thank you.</p>