def run(self): from Datas.Globals import worlds_locks file_name = "User_code." + self.name import_file = importlib.import_module(file_name, package="User_code") worlds_locks[self.name].acquire() import_file.declaration() Interface.add_methods("turtle", import_file.turtles_methods_dictionary) Interface.add_methods("patch", import_file.patches_methods_dictionary) import_file.setup() worlds_locks[self.name].release() while self.run_bool == True: worlds_locks[self.name].acquire() self.world_processing(import_file.go) worlds_locks[self.name].release()
def run(self): from Datas.Globals import worlds_locks # Load the file corresponding to this world file_name = "User_code." + self.name import_file = importlib.import_module(file_name, package="User_code") worlds_locks[self.name].acquire() # The declaration method creates new classes and add attributes to existing ones import_file.declaration() # Add every methods created by the user to their class Interface.add_methods("turtle", import_file.turtles_methods_dictionary) Interface.add_methods("patch", import_file.patches_methods_dictionary) # Setup the world with the initial values given by the user import_file.setup() worlds_locks[self.name].release() while self.run_bool == True : worlds_locks[self.name].acquire() self.world_processing(import_file.go) worlds_locks[self.name].release() time.sleep(self.sleep_time)