Reading data from a specific address / object link

How can I read (and enter into a new variable) data stored at a specific memory address?

For example, I know that:

  <nfqueue.queue; proxy of <Swig Object of type 'queue *' at 0xabd2b00> >

And I want to have the data stored in 0xabd2b00 in a new variable so that I can work and use all the functionality of the object. Suppose I do not have access to the source variable that created this object.

UPDATE: This question has been answered, so I am updating my question. Suppose I have two python files: file1.py and file2.py

File1.py:

.... rest of the code ....
class new_thread(threading.Thread):

    def __init__(self, obj):
       self.obj = obj
       threading.Thread.__init__(self)

    def run(self):
        str = 'python file2.py'
        args = shlex.split(str3)
        tmp = subprocess.Popen(args, stdout=open('/dev/null','w'), stderr=open('/dev/null', 'w'))
.... rest of the code ....

At some point, the new_thread thread is called.

File2.py:

kolejka = nfqueue.queue()

, . . - kolejka, file1.py , "" . kolejka , new_thread?

:

from file2 import kolejka

script ( ).

+3
1

- . ( ) , .

, , , , , . .


-

Python (, multiprocessing). , . file2 new_thread, , , signal, new_thread file2 .

file2.py , , , file1.py , file2.py, .

file1.py

def run(self):
    ...
    child_process = subprocess.Popen(args, ...)
    ...
    # time to quit - tell file2 to terminate
    child_process.terminate()

file2.py

import signal
import sys
...
kolejka = nfqueue.queue()
...
def sigterm_handler(signum, frame):
    # close kolejka and do any other cleanup needed, then do:
    sys.exit()

# Make sure sigterm_handler() is run when file1.py tells us
# to quit using child_process.terminate()
signal.signal(signal.SIGTERM, sigterm_handler)
+4

Source: https://habr.com/ru/post/1781611/


All Articles