Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8778581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:34:33+00:00 2026-06-13T19:34:33+00:00

I use Multiprocessing in Python in order to do several requests to a database

  • 0

I use Multiprocessing in Python in order to do several requests to a database (and other stuff):

po = multiprocessing.Pool()
for element in setOfElements:
    results.append(po.apply_async(myDBRequestModule, (element, other stuff...)))                    
po.close()
po.join()
for r in results:
    newSet.add(r.get())

myDBRequestModule returns an object I defined, made of a list and two numbers. I redefined the hash function, in order to define what I mean by equality in my sets of these objects:

class myObject:
    def __init__(self, aList, aNumber, anotherNumber):
        self.list = aList
        self.number1 = aNumber
        self.number2 = anotherNumber
    def __hash__(self):
        # turn elements of list into a string, in order to hash the string
        hash_text = ""
        for element in self.list:
            hash_text += str(element.x.id) # I use the ID of the element of my list...
        return hash(hash_text)
    def __eq__(self, other):
        self_hash_text = ""
        other_hash_text = ""
        for element in self.list:
            self_hash_text += str(element.x.id)
        for element in other.listDest:
            other_hash_text += str(element.x.id)
        return self_hash_text == other_hash_text 

And in most cases it works as it should. Twice, for no known reason and in exactly the same context, I had a bug:

newSet.add(r.get())
File "/usr/lib/python2.6/multiprocessing/pool.py", line 422, in get
    raise self._value
TypeError: 'str' object does not support item assignment

It comes from the get method (last line):

def get(self, timeout=None):
    self.wait(timeout)
    if not self._ready:
        raise TimeoutError
    if self._success:
        return self._value
    else:
        raise self._value

Since I had this mistake only once and it disappeared, I decided to give up earlier, but it created a second problem recently, and I really don’t know how to fight this bug.
In particular, it’s difficult for me to tell why it happens almost never, and usually works perfectly fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:34:34+00:00Added an answer on June 13, 2026 at 7:34 pm

    multiprocessing is not the issue here.

    You have not given us the right code to diagnose the issue. At some point you have assigned a caught exception to self._value. That is where the error is occurring. Look at everywhere that self._value is assigned and you will be on your way to finding this error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In python we can use multiprocessing modules. If there is a similar library in
I have a downloader function that downloads multiple files parallely. I use multiprocessing.Pool.map_async in
I'm trying to use python's multiprocessing module to run a distributed task over a
I want to use Python's multiprocessing to do concurrent processing without using locks (locks
Possible Duplicate: Multiprocessing launching too many instances of Python VM I'm trying to use
I try to use Pool from the multiprocessing module to speed up reading in
I'm trying to use a queue with the multiprocessing library in Python. After executing
I am trying to use a worker Pool in python using Process objects. Each
I'm trying to use the multiprocessing module in python 2.6, but apparently there is
I'm trying to learn how to use Python's multiprocessing package, but I don't understand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.