problem in implementing multiprocessing

Discussion in 'Python' started by gopal mishra, Jan 16, 2009.

  1. gopal mishra

    gopal mishra Guest

    Hello,

    I am trying to implement the multiprocessing in my application to take
    advantage of multiple cores. I have created two

    Separate process something like this.

    que = Queue
    Process(target = getData, args=(que , section, MdbFile,)).start()
    Process(target = getData, args=(que , section, MdbFile,)).start()

    In getData function I create the object(max 7MB size) and add in to queue
    (que.put (object)).

    After that I fetch the object using que.get () and use in my application.
    but it takes more time to get the data.

    Any one can help me out this problem.

    Thanks,
    Sibtey

    My code<<<<<
    from multiprocessing import Process, Queue

    def getData(queue, section, mdbFile):
    """
    This function returns the gapappdata for the given mdb file.
    """
    app = MdbFile(mdbFile)
    mdbData = app.data#it is a heavy object
    queue.put((section,mdbData))

    def getData2(mdbFile):
    """
    This function returns the gapappdata for the given mdb file.
    """
    app = MdbFile(mdbFile)
    mdbData = app.data#it is a heavy object
    return mdbData

    def test_multipleProcess(fromMdbFile, toMdbFile):
    #multipleProcess
    t1 = time.time()
    queue = Queue()
    sections = ['From', 'To']
    Process(target= getData_1, args=(queue, 'From',fromMdbFile,)).start()
    Process(target= getData_1, args=(queue, 'To',toMdbFile,)).start()
    section, gapAppData = queue.get()
    section, gapAppData = queue.get()
    t2 = time.time()
    print "total time using multiProcessing:",t2-t1
    d1 = getData2(fromMdbFile)
    d2 = getData2(toMdbFile)
    print "total time withought multiProcessing:", time.time()-t2





    if __name__=='__main__':
    f1 =r" a.mdb"
    f2 =r"b.mdb"
    test_multipleProcess(f1,f2)
     
    gopal mishra, Jan 16, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Mills
    Replies:
    2
    Views:
    312
    Aaron Brady
    Jan 19, 2009
  2. Wu Zhe
    Replies:
    2
    Views:
    486
    Piet van Oostrum
    May 27, 2009
  3. Replies:
    3
    Views:
    310
    Tennessee
    Sep 4, 2009
  4. Metalone
    Replies:
    0
    Views:
    224
    Metalone
    Jan 6, 2010
  5. Robert Kern
    Replies:
    2
    Views:
    324
    Wolodja Wentland
    Jan 12, 2010
Loading...

Share This Page