title: AttributeError: Can't pickle local object 'computation.. function1 using multiprocessing queue
body: <p>I have the following code using the scheduler and multiprocessing module:</p>
  
  <pre><code>def computation():
      def function1(q):
          while True:
              daydate = datetime.now()
              number = random.randrange(1, 215)
              print('Sent to function2: ({}, {})'.format(daydate, number))
              q.put((daydate, number))
              time.sleep(2)
  
      def function2(q):
          while True:
              date, number = q.get()
              print("Recevied values from function1: ({}, {})".format(date, number))
              time.sleep(2)
  
      if __name__ == "__main__":
          q = Queue()
          a = Process(target=function1, args=(q,))
          a.start()
          b = Process(target=function2, args=(q,))
          b.start()
          a.join()
          b.join()
  
  schedule.every().monday.at("08:45").do(computation)
  schedule.every().tuesday.at("08:45").do(computation)
  
  while True:
      schedule.run_pending()
      time.sleep(1)
  </code></pre>
  
  <p>However while executing the code gives the following error:</p>
  
  <blockquote>
    <p>AttributeError: Can't pickle local object 'computation..
    function1</p>
  </blockquote>
  
  <p>And:</p>
  
  <blockquote>
    <p>OSError: [WinError 87] The parameter is incorrect</p>
  </blockquote>
  
  <p>How does one solve this problem? I've tried to solve this by define a function at the top level of a module as stated in the documents (<a href="https://docs.python.org/2/library/pickle.html#what-can-be-pickled-and-unpickled" rel="nofollow noreferrer">https://docs.python.org/2/library/pickle.html#what-can-be-pickled-and-unpickled</a>) however it still gives the same error.</p>