[Tutor] running a game server
Alan Gauld
alan.gauld at yahoo.co.uk
Sun Jan 6 17:27:34 EST 2019
On 06/01/2019 20:40, nathan tech wrote:
> Hi Alan,
>
> Thanks for the swift response.
>
> Are there any places in python code I need to free variables?
Its more about not hanging on to them by accident. For example
putting them into a list and then deleting the original variable.
The reference in the list keeps the object alive even though
you think it's gone.
But mostly in Python if you let things drop out of scope they will
be garbage collected.
> going into this, is there anything obvious I should know that are best
> practices?
Only the things that are common to any server implementation.
Create single instances of any common data items before
entering the infinite loop. If you expect high volumes look at
using threads for each service request (or using async or
concurrency instead of threading, depending on your work types)
Also try to wrap up the services as pure functions with minimal
side effects. Don't use global variables inside the functions
if at all possible.
Beyond that, it all depends what you are trying to do and what
the expected volumes of both data and requests entail.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list