From 1fd0d1e2378519c52518412067aaf1d8ed7d8bdc Mon Sep 17 00:00:00 2001 From: arpruss Date: Sun, 21 Jun 2015 09:56:42 -0500 Subject: [PATCH] improve pypy workaround --- python2-scripts/mcpipy/mcpi/connection.py | 8 ++++++-- python2-scripts/mcpipy/text.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python2-scripts/mcpipy/mcpi/connection.py b/python2-scripts/mcpipy/mcpi/connection.py index 66534fd..c05e48a 100644 --- a/python2-scripts/mcpipy/mcpi/connection.py +++ b/python2-scripts/mcpipy/mcpi/connection.py @@ -3,6 +3,7 @@ import sys import atexit import os +import platform from util import flatten_parameters_to_string """ @author: Aron Nieminen, Mojang AB""" @@ -29,10 +30,13 @@ def __init__(self, address=None, port=None): self.socket.connect((address, port)) self.readFile = self.socket.makefile("r") self.lastSent = "" - atexit.register(self.close) + if platform.system() == "Windows": + atexit.register(self.close) def __del__(self): - self.close() + if platform.system() == "Windows": + self.close() + atexit.unregister(self.close) def close(self): try: diff --git a/python2-scripts/mcpipy/text.py b/python2-scripts/mcpipy/text.py index 7df3914..095da10 100644 --- a/python2-scripts/mcpipy/text.py +++ b/python2-scripts/mcpipy/text.py @@ -84,4 +84,4 @@ def angleToTextDirection(angle): del sys.argv[0] text = " ".join(sys.argv) - pos = drawText(mc, fonts.FONTS['tallfont'], pos, forward, minecraft.Vec3(0,1,0), text, foreground, background) + drawText(mc, fonts.FONTS['tallfont'], pos, forward, minecraft.Vec3(0,1,0), text, foreground, background)