I have a class Feed that inherits from multiprocessing.Process, it has a list within it. While the processes are running I need to be able to add to this list. Is this possible?
class Feed(multiprocessing.Process):
def __init__(self, user: str, feed_id: str, feed_name: str):
super(Feed, self).__init__()
self._user = user
self._feed_id = feed_id
self._feed_name = feed_name
self._connected_servers_store = []
def add_server(self, server_ip: str) -> None:
self._connected_servers_store.append(server_ip)
def run(self) -> None:
while True:
print(self._connected_servers_store)
I would like to be able to do this but haven't been able to find anything online that deals with this type of scenario. For the purposes of this application, the IP addresses cant be hardcoded in.
def main():
feed = Feed(user='1234', feed_id='12345', feed_name='Feed 1')
feed.start()
feed.add_server('127.0.0.1')
feed.add_server('<IP_ADDRESS>')
feed.add_server('<IP_ADDRESS>')
if __name__ == '__main__':
main()
When the program is running all that is printed is an empty list.