[env] Only call close() if service object is not None.
@@ -716,6 +716,7 @@ class CompilerEnv(gym.Env):
except (ServiceError, ServiceTransportError, TimeoutError) as e:
# Abort and retry on error.
self.logger.warning("%s on reset(): %s", type(e).__name__, e)
+ if self.service:
self.service.close()
self.service = None
