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 7182011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:40:42+00:00 2026-05-28T17:40:42+00:00

Please be so kind to point me on how can a list or an

  • 0

Please be so kind to point me on how can a list or an array be shared between processes so they can access/append/delete data from it? Do i need to use Manager for it?
For example i have code that pings several hosts using multiprocessing:

#!/usr/bin/env python

from multiprocessing import Pool
import os

def ping(ip):
  report = ("No response","Partial Response","Alive")
  pingaling = os.popen("ping -q -c2 "+str(ip),"r")
  while 1:
    line = pingaling.readline()
    try:
      result = line[line.find(','):].split()[1]
      output = report[int(result[0])]
    except:
      pass
    if not line: break
  print "Testing %s : %s!" % (ip, output)

if __name__ == '__main__':
  pool = Pool(processes=3)
  host = ['81.24.212.'+str(x) for x in range(10)]
  pool.map(ping, host, 1)
  pool.close()
  pool.join() 

But the output is unsorted, however i want to add output to an array and sort it:

Testing 81.24.212.1 : Alive!
Testing 81.24.212.2 : Alive!
Testing 81.24.212.6 : Alive!
Testing 81.24.212.0 : No response!
Testing 81.24.212.5 : No response!
Testing 81.24.212.3 : No response!
Testing 81.24.212.4 : No response!
Testing 81.24.212.9 : No response!
Testing 81.24.212.7 : No response!
Testing 81.24.212.8 : No response!
  • 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-05-28T17:40:44+00:00Added an answer on May 28, 2026 at 5:40 pm

    note that pool.map acts a lot like the buildin map function and like it returns a list of the results of the application of the given function to elements in the given list.

    so you need only have ping() return what it found and then do:

    list_of_values = pool.map(ping, host, 1)
    

    after which you can use the list_of_values any way you like

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

Sidebar

Related Questions

What kind of data structures are these? Can someone please point out any links
Can you please tell me what kind of construct in C# is this. Code
this kind of emergency, so please, can someone help me... I'm using movingboxes plugin
can anyone please point me in the right direction for a json database on
I'm trying to teach myself php... so please be kind and bear with me.
Please help me out here because im getting kind of confused.. I have a
I'm kind of a newbie with PHP so please bear with me. I would
I'm not sure what kind of terminology to use in this so please edit
I am trying to read floating point numbers from a file into a dynamically
First post, please be kind. NOTE: I have reviewed entry #20856 (how to implement

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.