Getting data into a manager.dict and sharing it between processes

I’m currently trying to teach myself how to handle live data by streaming Forza telemetry data from my xbox to my PC. I’m having issues storing that data in a manager.dict and sharing it to other processes. I’ve created a manager.dict called packets, here is the app.py:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>from connectors.forza_connect import forza_connect, forza_record
from telemetry_utils import throttle
from multiprocessing import Manager, Process
if __name__ == '__main__':
with Manager() as manager:
packets = manager.dict({}) # Create shared dict for the worker and UI to use
# Start the background data collection process
data_args = ('motorsport', packets, )
data_process = Process(target=forza_connect, args=data_args)
data_process.start()
throttle_process = Process(target=throttle.show_throttle_text, args=(packets, ))
throttle_process.start()
data_process.join()
throttle_process.join()
</code>
<code>from connectors.forza_connect import forza_connect, forza_record from telemetry_utils import throttle from multiprocessing import Manager, Process if __name__ == '__main__': with Manager() as manager: packets = manager.dict({}) # Create shared dict for the worker and UI to use # Start the background data collection process data_args = ('motorsport', packets, ) data_process = Process(target=forza_connect, args=data_args) data_process.start() throttle_process = Process(target=throttle.show_throttle_text, args=(packets, )) throttle_process.start() data_process.join() throttle_process.join() </code>
from connectors.forza_connect import forza_connect, forza_record
from telemetry_utils import throttle
from multiprocessing import Manager, Process

if __name__ == '__main__':
    with Manager() as manager:
        packets = manager.dict({})   # Create shared dict for the worker and UI to use
    
        # Start the background data collection process
        data_args = ('motorsport', packets, )                      
        data_process = Process(target=forza_connect, args=data_args)  
        data_process.start()

        throttle_process = Process(target=throttle.show_throttle_text, args=(packets, ))
        throttle_process.start()

        data_process.join()
        throttle_process.join()

This runs forza_connect which collects the data and transforms it into a dictionary, this bit works fine on its own but it doesn’t seem to send that data back in to packets. Here’s the forza_connect.py:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import socket
from data_utils import forza_data
def forza_connect(game_version, packets, local_ip='0.0.0.0', port=5555, to_print=False, fd=forza_data):
## Connect to Forza
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((local_ip, port))
#sock.settimeout(5)
fd = fd.ForzaData(game_version)
while True:
packet, packet_source = sock.recvfrom(1024) # Receive data
fd.parse(packet) # Parse data
# Append packet to the shared list
for k, v in fd.to_dict().items():
packets[k].append(v)
sock.close() # Close the socket
</code>
<code>import socket from data_utils import forza_data def forza_connect(game_version, packets, local_ip='0.0.0.0', port=5555, to_print=False, fd=forza_data): ## Connect to Forza sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind((local_ip, port)) #sock.settimeout(5) fd = fd.ForzaData(game_version) while True: packet, packet_source = sock.recvfrom(1024) # Receive data fd.parse(packet) # Parse data # Append packet to the shared list for k, v in fd.to_dict().items(): packets[k].append(v) sock.close() # Close the socket </code>
import socket
from data_utils import forza_data   

def forza_connect(game_version, packets, local_ip='0.0.0.0', port=5555, to_print=False, fd=forza_data):

    ## Connect to Forza
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind((local_ip, port))
    #sock.settimeout(5)

    fd = fd.ForzaData(game_version)

    while True:
        packet, packet_source = sock.recvfrom(1024) # Receive data
        fd.parse(packet)                            # Parse data             
    
        # Append packet to the shared list
        for k, v in fd.to_dict().items():
            packets[k].append(v)
    
    sock.close()                                    # Close the socket

I want the data collected above to be available to multiple processes, however no data seems to be being stored and no data is getting sent to throttle.py

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Show throttle percentage as text
def show_throttle_text(forza_data):
#print(f"r throttle percentage: {int(forza_data['throttle'])}", end='', flush=True)
print(forza_data)
</code>
<code># Show throttle percentage as text def show_throttle_text(forza_data): #print(f"r throttle percentage: {int(forza_data['throttle'])}", end='', flush=True) print(forza_data) </code>
# Show throttle percentage as text
def show_throttle_text(forza_data):
    #print(f"r throttle percentage: {int(forza_data['throttle'])}", end='', flush=True)
    print(forza_data)

This currently just showing an empty dict. What is it I am mis-understanding about how to use this? Thanks

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật