We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
DefaultWorker crashes in non-deterministic mode
```sh
  File "/home/rjulian/venv/lib/python3.5/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/rjulian/venv/lib/python3.5/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/rjulian/venv/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rjulian/venv/lib/python3.5/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "examples/torch/sac_metaworldv2_test.py", line 102, in get_args
    sac_metaworldv2_test()
  File "/home/rjulian/garage/src/garage/experiment/experiment.py", line 553, in __call__
    result = self.function(ctxt, **kwargs)
  File "examples/torch/sac_metaworldv2_test.py", line 100, in sac_metaworldv2_test
    runner.setup(algo=sac, env=env, sampler_cls=LocalSampler)
  File "/home/rjulian/garage/src/garage/experiment/local_runner.py", line 268, in setup
    worker_args=worker_args)
  File "/home/rjulian/garage/src/garage/experiment/local_runner.py", line 215, in make_sampler
    envs=self._env)
  File "/home/rjulian/garage/src/garage/sampler/local_sampler.py", line 66, in from_worker_factory
    return cls(worker_factory, agents, envs)
  File "/home/rjulian/garage/src/garage/sampler/local_sampler.py", line 38, in __init__
    worker_factory(i) for i in range(worker_factory.n_workers)
  File "/home/rjulian/garage/src/garage/sampler/local_sampler.py", line 38, in <listcomp>
    worker_factory(i) for i in range(worker_factory.n_workers)
  File "/home/rjulian/garage/src/garage/sampler/worker_factory.py", line 109, in __call__
    **self._worker_args)
  File "/home/rjulian/garage/src/garage/sampler/default_worker.py", line 51, in __init__
    self.worker_init()
  File "/home/rjulian/garage/src/garage/sampler/default_worker.py", line 55, in worker_init
    deterministic.set_seed(self._seed + self._worker_number)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/garage/sampler/default_worker.py`
Content:
```
1 """Default Worker class."""
2 from collections import defaultdict
3 
4 import gym
5 import numpy as np
6 
7 from garage import TrajectoryBatch
8 from garage.experiment import deterministic
9 from garage.sampler.env_update import EnvUpdate
10 from garage.sampler.worker import Worker
11 
12 
13 class DefaultWorker(Worker):
14     """Initialize a worker.
15 
16     Args:
17         seed(int): The seed to use to intialize random number generators.
18         max_path_length(int or float): The maximum length paths which will
19             be sampled. Can be (floating point) infinity.
20         worker_number(int): The number of the worker where this update is
21             occurring. This argument is used to set a different seed for each
22             worker.
23 
24     Attributes:
25         agent(Policy or None): The worker's agent.
26         env(gym.Env or None): The worker's environment.
27 
28     """
29 
30     def __init__(
31             self,
32             *,  # Require passing by keyword, since everything's an int.
33             seed,
34             max_path_length,
35             worker_number):
36         super().__init__(seed=seed,
37                          max_path_length=max_path_length,
38                          worker_number=worker_number)
39         self.agent = None
40         self.env = None
41         self._observations = []
42         self._last_observations = []
43         self._actions = []
44         self._rewards = []
45         self._terminals = []
46         self._lengths = []
47         self._agent_infos = defaultdict(list)
48         self._env_infos = defaultdict(list)
49         self._prev_obs = None
50         self._path_length = 0
51         self.worker_init()
52 
53     def worker_init(self):
54         """Initialize a worker."""
55         deterministic.set_seed(self._seed + self._worker_number)
56 
57     def update_agent(self, agent_update):
58         """Update an agent, assuming it implements garage.Policy.
59 
60         Args:
61             agent_update (np.ndarray or dict or garage.Policy): If a
62                 tuple, dict, or np.ndarray, these should be parameters to
63                 agent, which should have been generated by calling
64                 `policy.get_param_values`. Alternatively, a policy itself. Note
65                 that other implementations of `Worker` may take different types
66                 for this parameter.
67 
68         """
69         if isinstance(agent_update, (dict, tuple, np.ndarray)):
70             self.agent.set_param_values(agent_update)
71         elif agent_update is not None:
72             self.agent = agent_update
73 
74     def update_env(self, env_update):
75         """Use any non-None env_update as a new environment.
76 
77         A simple env update function. If env_update is not None, it should be
78         the complete new environment.
79 
80         This allows changing environments by passing the new environment as
81         `env_update` into `obtain_samples`.
82 
83         Args:
84             env_update(gym.Env or EnvUpdate or None): The environment to
85                 replace the existing env with. Note that other implementations
86                 of `Worker` may take different types for this parameter.
87 
88         Raises:
89             TypeError: If env_update is not one of the documented types.
90 
91         """
92         if env_update is not None:
93             if isinstance(env_update, EnvUpdate):
94                 self.env = env_update(self.env)
95             elif isinstance(env_update, gym.Env):
96                 if self.env is not None:
97                     self.env.close()
98                 self.env = env_update
99             else:
100                 raise TypeError('Uknown environment update type.')
101 
102     def start_rollout(self):
103         """Begin a new rollout."""
104         self._path_length = 0
105         self._prev_obs = self.env.reset()
106         self.agent.reset()
107 
108     def step_rollout(self):
109         """Take a single time-step in the current rollout.
110 
111         Returns:
112             bool: True iff the path is done, either due to the environment
113             indicating termination of due to reaching `max_path_length`.
114 
115         """
116         if self._path_length < self._max_path_length:
117             a, agent_info = self.agent.get_action(self._prev_obs)
118             next_o, r, d, env_info = self.env.step(a)
119             self._observations.append(self._prev_obs)
120             self._rewards.append(r)
121             self._actions.append(a)
122             for k, v in agent_info.items():
123                 self._agent_infos[k].append(v)
124             for k, v in env_info.items():
125                 self._env_infos[k].append(v)
126             self._path_length += 1
127             self._terminals.append(d)
128             if not d:
129                 self._prev_obs = next_o
130                 return False
131         self._lengths.append(self._path_length)
132         self._last_observations.append(self._prev_obs)
133         return True
134 
135     def collect_rollout(self):
136         """Collect the current rollout, clearing the internal buffer.
137 
138         Returns:
139             garage.TrajectoryBatch: A batch of the trajectories completed since
140                 the last call to collect_rollout().
141 
142         """
143         observations = self._observations
144         self._observations = []
145         last_observations = self._last_observations
146         self._last_observations = []
147         actions = self._actions
148         self._actions = []
149         rewards = self._rewards
150         self._rewards = []
151         terminals = self._terminals
152         self._terminals = []
153         env_infos = self._env_infos
154         self._env_infos = defaultdict(list)
155         agent_infos = self._agent_infos
156         self._agent_infos = defaultdict(list)
157         for k, v in agent_infos.items():
158             agent_infos[k] = np.asarray(v)
159         for k, v in env_infos.items():
160             env_infos[k] = np.asarray(v)
161         lengths = self._lengths
162         self._lengths = []
163         return TrajectoryBatch(self.env.spec, np.asarray(observations),
164                                np.asarray(last_observations),
165                                np.asarray(actions), np.asarray(rewards),
166                                np.asarray(terminals), dict(env_infos),
167                                dict(agent_infos), np.asarray(lengths,
168                                                              dtype='i'))
169 
170     def rollout(self):
171         """Sample a single rollout of the agent in the environment.
172 
173         Returns:
174             garage.TrajectoryBatch: The collected trajectory.
175 
176         """
177         self.start_rollout()
178         while not self.step_rollout():
179             pass
180         return self.collect_rollout()
181 
182     def shutdown(self):
183         """Close the worker's environment."""
184         self.env.close()
185
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/garage/sampler/default_worker.py b/src/garage/sampler/default_worker.py
--- a/src/garage/sampler/default_worker.py
+++ b/src/garage/sampler/default_worker.py
@@ -52,7 +52,8 @@
 
     def worker_init(self):
         """Initialize a worker."""
-        deterministic.set_seed(self._seed + self._worker_number)
+        if self._seed is not None:
+            deterministic.set_seed(self._seed + self._worker_number)
 
     def update_agent(self, agent_update):
         """Update an agent, assuming it implements garage.Policy.

{"golden_diff": "diff --git a/src/garage/sampler/default_worker.py b/src/garage/sampler/default_worker.py\n--- a/src/garage/sampler/default_worker.py\n+++ b/src/garage/sampler/default_worker.py\n@@ -52,7 +52,8 @@\n \n     def worker_init(self):\n         \"\"\"Initialize a worker.\"\"\"\n-        deterministic.set_seed(self._seed + self._worker_number)\n+        if self._seed is not None:\n+            deterministic.set_seed(self._seed + self._worker_number)\n \n     def update_agent(self, agent_update):\n         \"\"\"Update an agent, assuming it implements garage.Policy.\n", "issue": "DefaultWorker crashes in non-deterministic mode\n```sh\r\n  File \"/home/rjulian/venv/lib/python3.5/site-packages/click/core.py\", line 829, in __call__\r\n    return self.main(*args, **kwargs)\r\n  File \"/home/rjulian/venv/lib/python3.5/site-packages/click/core.py\", line 782, in main\r\n    rv = self.invoke(ctx)\r\n  File \"/home/rjulian/venv/lib/python3.5/site-packages/click/core.py\", line 1066, in invoke\r\n    return ctx.invoke(self.callback, **ctx.params)\r\n  File \"/home/rjulian/venv/lib/python3.5/site-packages/click/core.py\", line 610, in invoke\r\n    return callback(*args, **kwargs)\r\n  File \"examples/torch/sac_metaworldv2_test.py\", line 102, in get_args\r\n    sac_metaworldv2_test()\r\n  File \"/home/rjulian/garage/src/garage/experiment/experiment.py\", line 553, in __call__\r\n    result = self.function(ctxt, **kwargs)\r\n  File \"examples/torch/sac_metaworldv2_test.py\", line 100, in sac_metaworldv2_test\r\n    runner.setup(algo=sac, env=env, sampler_cls=LocalSampler)\r\n  File \"/home/rjulian/garage/src/garage/experiment/local_runner.py\", line 268, in setup\r\n    worker_args=worker_args)\r\n  File \"/home/rjulian/garage/src/garage/experiment/local_runner.py\", line 215, in make_sampler\r\n    envs=self._env)\r\n  File \"/home/rjulian/garage/src/garage/sampler/local_sampler.py\", line 66, in from_worker_factory\r\n    return cls(worker_factory, agents, envs)\r\n  File \"/home/rjulian/garage/src/garage/sampler/local_sampler.py\", line 38, in __init__\r\n    worker_factory(i) for i in range(worker_factory.n_workers)\r\n  File \"/home/rjulian/garage/src/garage/sampler/local_sampler.py\", line 38, in <listcomp>\r\n    worker_factory(i) for i in range(worker_factory.n_workers)\r\n  File \"/home/rjulian/garage/src/garage/sampler/worker_factory.py\", line 109, in __call__\r\n    **self._worker_args)\r\n  File \"/home/rjulian/garage/src/garage/sampler/default_worker.py\", line 51, in __init__\r\n    self.worker_init()\r\n  File \"/home/rjulian/garage/src/garage/sampler/default_worker.py\", line 55, in worker_init\r\n    deterministic.set_seed(self._seed + self._worker_number)\r\nTypeError: unsupported operand type(s) for +: 'NoneType' and 'int'\r\n```\n", "before_files": [{"content": "\"\"\"Default Worker class.\"\"\"\nfrom collections import defaultdict\n\nimport gym\nimport numpy as np\n\nfrom garage import TrajectoryBatch\nfrom garage.experiment import deterministic\nfrom garage.sampler.env_update import EnvUpdate\nfrom garage.sampler.worker import Worker\n\n\nclass DefaultWorker(Worker):\n    \"\"\"Initialize a worker.\n\n    Args:\n        seed(int): The seed to use to intialize random number generators.\n        max_path_length(int or float): The maximum length paths which will\n            be sampled. Can be (floating point) infinity.\n        worker_number(int): The number of the worker where this update is\n            occurring. This argument is used to set a different seed for each\n            worker.\n\n    Attributes:\n        agent(Policy or None): The worker's agent.\n        env(gym.Env or None): The worker's environment.\n\n    \"\"\"\n\n    def __init__(\n            self,\n            *,  # Require passing by keyword, since everything's an int.\n            seed,\n            max_path_length,\n            worker_number):\n        super().__init__(seed=seed,\n                         max_path_length=max_path_length,\n                         worker_number=worker_number)\n        self.agent = None\n        self.env = None\n        self._observations = []\n        self._last_observations = []\n        self._actions = []\n        self._rewards = []\n        self._terminals = []\n        self._lengths = []\n        self._agent_infos = defaultdict(list)\n        self._env_infos = defaultdict(list)\n        self._prev_obs = None\n        self._path_length = 0\n        self.worker_init()\n\n    def worker_init(self):\n        \"\"\"Initialize a worker.\"\"\"\n        deterministic.set_seed(self._seed + self._worker_number)\n\n    def update_agent(self, agent_update):\n        \"\"\"Update an agent, assuming it implements garage.Policy.\n\n        Args:\n            agent_update (np.ndarray or dict or garage.Policy): If a\n                tuple, dict, or np.ndarray, these should be parameters to\n                agent, which should have been generated by calling\n                `policy.get_param_values`. Alternatively, a policy itself. Note\n                that other implementations of `Worker` may take different types\n                for this parameter.\n\n        \"\"\"\n        if isinstance(agent_update, (dict, tuple, np.ndarray)):\n            self.agent.set_param_values(agent_update)\n        elif agent_update is not None:\n            self.agent = agent_update\n\n    def update_env(self, env_update):\n        \"\"\"Use any non-None env_update as a new environment.\n\n        A simple env update function. If env_update is not None, it should be\n        the complete new environment.\n\n        This allows changing environments by passing the new environment as\n        `env_update` into `obtain_samples`.\n\n        Args:\n            env_update(gym.Env or EnvUpdate or None): The environment to\n                replace the existing env with. Note that other implementations\n                of `Worker` may take different types for this parameter.\n\n        Raises:\n            TypeError: If env_update is not one of the documented types.\n\n        \"\"\"\n        if env_update is not None:\n            if isinstance(env_update, EnvUpdate):\n                self.env = env_update(self.env)\n            elif isinstance(env_update, gym.Env):\n                if self.env is not None:\n                    self.env.close()\n                self.env = env_update\n            else:\n                raise TypeError('Uknown environment update type.')\n\n    def start_rollout(self):\n        \"\"\"Begin a new rollout.\"\"\"\n        self._path_length = 0\n        self._prev_obs = self.env.reset()\n        self.agent.reset()\n\n    def step_rollout(self):\n        \"\"\"Take a single time-step in the current rollout.\n\n        Returns:\n            bool: True iff the path is done, either due to the environment\n            indicating termination of due to reaching `max_path_length`.\n\n        \"\"\"\n        if self._path_length < self._max_path_length:\n            a, agent_info = self.agent.get_action(self._prev_obs)\n            next_o, r, d, env_info = self.env.step(a)\n            self._observations.append(self._prev_obs)\n            self._rewards.append(r)\n            self._actions.append(a)\n            for k, v in agent_info.items():\n                self._agent_infos[k].append(v)\n            for k, v in env_info.items():\n                self._env_infos[k].append(v)\n            self._path_length += 1\n            self._terminals.append(d)\n            if not d:\n                self._prev_obs = next_o\n                return False\n        self._lengths.append(self._path_length)\n        self._last_observations.append(self._prev_obs)\n        return True\n\n    def collect_rollout(self):\n        \"\"\"Collect the current rollout, clearing the internal buffer.\n\n        Returns:\n            garage.TrajectoryBatch: A batch of the trajectories completed since\n                the last call to collect_rollout().\n\n        \"\"\"\n        observations = self._observations\n        self._observations = []\n        last_observations = self._last_observations\n        self._last_observations = []\n        actions = self._actions\n        self._actions = []\n        rewards = self._rewards\n        self._rewards = []\n        terminals = self._terminals\n        self._terminals = []\n        env_infos = self._env_infos\n        self._env_infos = defaultdict(list)\n        agent_infos = self._agent_infos\n        self._agent_infos = defaultdict(list)\n        for k, v in agent_infos.items():\n            agent_infos[k] = np.asarray(v)\n        for k, v in env_infos.items():\n            env_infos[k] = np.asarray(v)\n        lengths = self._lengths\n        self._lengths = []\n        return TrajectoryBatch(self.env.spec, np.asarray(observations),\n                               np.asarray(last_observations),\n                               np.asarray(actions), np.asarray(rewards),\n                               np.asarray(terminals), dict(env_infos),\n                               dict(agent_infos), np.asarray(lengths,\n                                                             dtype='i'))\n\n    def rollout(self):\n        \"\"\"Sample a single rollout of the agent in the environment.\n\n        Returns:\n            garage.TrajectoryBatch: The collected trajectory.\n\n        \"\"\"\n        self.start_rollout()\n        while not self.step_rollout():\n            pass\n        return self.collect_rollout()\n\n    def shutdown(self):\n        \"\"\"Close the worker's environment.\"\"\"\n        self.env.close()\n", "path": "src/garage/sampler/default_worker.py"}], "after_files": [{"content": "\"\"\"Default Worker class.\"\"\"\nfrom collections import defaultdict\n\nimport gym\nimport numpy as np\n\nfrom garage import TrajectoryBatch\nfrom garage.experiment import deterministic\nfrom garage.sampler.env_update import EnvUpdate\nfrom garage.sampler.worker import Worker\n\n\nclass DefaultWorker(Worker):\n    \"\"\"Initialize a worker.\n\n    Args:\n        seed(int): The seed to use to intialize random number generators.\n        max_path_length(int or float): The maximum length paths which will\n            be sampled. Can be (floating point) infinity.\n        worker_number(int): The number of the worker where this update is\n            occurring. This argument is used to set a different seed for each\n            worker.\n\n    Attributes:\n        agent(Policy or None): The worker's agent.\n        env(gym.Env or None): The worker's environment.\n\n    \"\"\"\n\n    def __init__(\n            self,\n            *,  # Require passing by keyword, since everything's an int.\n            seed,\n            max_path_length,\n            worker_number):\n        super().__init__(seed=seed,\n                         max_path_length=max_path_length,\n                         worker_number=worker_number)\n        self.agent = None\n        self.env = None\n        self._observations = []\n        self._last_observations = []\n        self._actions = []\n        self._rewards = []\n        self._terminals = []\n        self._lengths = []\n        self._agent_infos = defaultdict(list)\n        self._env_infos = defaultdict(list)\n        self._prev_obs = None\n        self._path_length = 0\n        self.worker_init()\n\n    def worker_init(self):\n        \"\"\"Initialize a worker.\"\"\"\n        if self._seed is not None:\n            deterministic.set_seed(self._seed + self._worker_number)\n\n    def update_agent(self, agent_update):\n        \"\"\"Update an agent, assuming it implements garage.Policy.\n\n        Args:\n            agent_update (np.ndarray or dict or garage.Policy): If a\n                tuple, dict, or np.ndarray, these should be parameters to\n                agent, which should have been generated by calling\n                `policy.get_param_values`. Alternatively, a policy itself. Note\n                that other implementations of `Worker` may take different types\n                for this parameter.\n\n        \"\"\"\n        if isinstance(agent_update, (dict, tuple, np.ndarray)):\n            self.agent.set_param_values(agent_update)\n        elif agent_update is not None:\n            self.agent = agent_update\n\n    def update_env(self, env_update):\n        \"\"\"Use any non-None env_update as a new environment.\n\n        A simple env update function. If env_update is not None, it should be\n        the complete new environment.\n\n        This allows changing environments by passing the new environment as\n        `env_update` into `obtain_samples`.\n\n        Args:\n            env_update(gym.Env or EnvUpdate or None): The environment to\n                replace the existing env with. Note that other implementations\n                of `Worker` may take different types for this parameter.\n\n        Raises:\n            TypeError: If env_update is not one of the documented types.\n\n        \"\"\"\n        if env_update is not None:\n            if isinstance(env_update, EnvUpdate):\n                self.env = env_update(self.env)\n            elif isinstance(env_update, gym.Env):\n                if self.env is not None:\n                    self.env.close()\n                self.env = env_update\n            else:\n                raise TypeError('Uknown environment update type.')\n\n    def start_rollout(self):\n        \"\"\"Begin a new rollout.\"\"\"\n        self._path_length = 0\n        self._prev_obs = self.env.reset()\n        self.agent.reset()\n\n    def step_rollout(self):\n        \"\"\"Take a single time-step in the current rollout.\n\n        Returns:\n            bool: True iff the path is done, either due to the environment\n            indicating termination of due to reaching `max_path_length`.\n\n        \"\"\"\n        if self._path_length < self._max_path_length:\n            a, agent_info = self.agent.get_action(self._prev_obs)\n            next_o, r, d, env_info = self.env.step(a)\n            self._observations.append(self._prev_obs)\n            self._rewards.append(r)\n            self._actions.append(a)\n            for k, v in agent_info.items():\n                self._agent_infos[k].append(v)\n            for k, v in env_info.items():\n                self._env_infos[k].append(v)\n            self._path_length += 1\n            self._terminals.append(d)\n            if not d:\n                self._prev_obs = next_o\n                return False\n        self._lengths.append(self._path_length)\n        self._last_observations.append(self._prev_obs)\n        return True\n\n    def collect_rollout(self):\n        \"\"\"Collect the current rollout, clearing the internal buffer.\n\n        Returns:\n            garage.TrajectoryBatch: A batch of the trajectories completed since\n                the last call to collect_rollout().\n\n        \"\"\"\n        observations = self._observations\n        self._observations = []\n        last_observations = self._last_observations\n        self._last_observations = []\n        actions = self._actions\n        self._actions = []\n        rewards = self._rewards\n        self._rewards = []\n        terminals = self._terminals\n        self._terminals = []\n        env_infos = self._env_infos\n        self._env_infos = defaultdict(list)\n        agent_infos = self._agent_infos\n        self._agent_infos = defaultdict(list)\n        for k, v in agent_infos.items():\n            agent_infos[k] = np.asarray(v)\n        for k, v in env_infos.items():\n            env_infos[k] = np.asarray(v)\n        lengths = self._lengths\n        self._lengths = []\n        return TrajectoryBatch(self.env.spec, np.asarray(observations),\n                               np.asarray(last_observations),\n                               np.asarray(actions), np.asarray(rewards),\n                               np.asarray(terminals), dict(env_infos),\n                               dict(agent_infos), np.asarray(lengths,\n                                                             dtype='i'))\n\n    def rollout(self):\n        \"\"\"Sample a single rollout of the agent in the environment.\n\n        Returns:\n            garage.TrajectoryBatch: The collected trajectory.\n\n        \"\"\"\n        self.start_rollout()\n        while not self.step_rollout():\n            pass\n        return self.collect_rollout()\n\n    def shutdown(self):\n        \"\"\"Close the worker's environment.\"\"\"\n        self.env.close()\n", "path": "src/garage/sampler/default_worker.py"}]}