The error is usually related to manual management of memory.Python connects with an external library performs manual memory management, it may not automatically manage the memory, and in case it doesn't work, the memory is freed up or only once