Monitoring Function namespace

I have a code that creates a SERVER (the protocol is MODBUS) and another code to create a CLIENT. the server code keeps running while the client code reads the data from server (data that has been given as initialisation in the code).

I want to know if it is posible to see the namespace of the server , I mean, I want to see its own data online (lika a box) that is avaiable so that when the CLIENT write something in the server, I can see the final action on the namespace of the SERVER. I know the CLIENT/SERVER perform these actions write/read but I want to have a third party application that show the overall system behaviour.

I was thinking an extension of an IDE (pycharm)…

When you say that you want to “see” the namespace - see it from where?

In general, a client can only know things about the server that the server explicitly tells the client. That’s a consequence of how the Internet works (specifically, how sockets work), and is nothing to do with Python.

If you want to monitor the program on the server, that’s what debuggers, profilers etc. are for.

Thanks Karl,
I mean to see the name space from the IDE.

How to use the debugger for this purpose? a breaking point will stop the program to finish …(this is maybe a very basic question, but I will apreciate your help)

You can also resume the program from where it stopped. (This might have consequences for a client trying to connect to or waiting on the server, but that depends on where the server has stopped.)

Here is diagram

You could design into your server an admin interface that allows you to get reports on the server internals. Often I have replied on this and debug logging when working on server code in production environments.

And just to take an even simpler approach, since you’re the author of
the server too, if you’re running the server by hand, eg in a terminal,
you might put various useful print() calls in the server code to
recite important things, like data received or the namespace info you
want etc.

This is just like debug logging (per Barry’s suggestion) but even
simpler.

You can insert calls to the following helper function at your points of interest (such as when the server is about to perform an action as a response) to dump into a log file the entire stack trace along with values of all local variables in each frame:

import sys
import traceback

def dump_stack(file=sys.stdout):
    print(
        *traceback.StackSummary.extract(
            traceback.walk_stack(sys._getframe(1)), capture_locals=True
        ).format(), sep='\n', file=file
    )

so that as an example:

def foo(b):
    c = b + 1
    dump_stack()

a = 1
foo(a)

would output something like:

  File "./prog.py", line 13, in foo
    b = 1
    c = 2

  File "./prog.py", line 16, in <module>
    __annotations__ = {}
    __builtins__ = <module 'builtins' (built-in)>
    __cached__ = None
    __doc__ = None
    __file__ = '/home/bgjPHS/./prog'
    __loader__ = <_frozen_importlib_external.SourcelessFileLoader object at 0x14ca185e5c10>
    __name__ = '__main__'
    __package__ = None
    __spec__ = None
    a = 1
    dump_stack = <function dump_stack at 0x14ca185b2040>
    foo = <function foo at 0x14ca183b7160>
    sys = <module 'sys' (built-in)>
    traceback = <module 'traceback' from '/usr/lib/python3.9/traceback.py'>

Demo: 4bgCb6 - Online Python3 Interpreter & Debugging Tool - Ideone.com