Skip to content

Commit

Permalink
BUG: Worker starts failed on windows (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengjieLi28 authored Dec 22, 2023
1 parent 5da3fd2 commit 0bf90da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions xinference/core/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,17 @@ async def __post_create__(self):
),
}

async def singal_handler():
await self._supervisor_ref.remove_worker(self.address)
os._exit(0)
# Windows does not have signal handler
if os.name != "nt":

loop = asyncio.get_running_loop()
loop.add_signal_handler(
signal.SIGINT, lambda: asyncio.create_task(singal_handler())
)
async def signal_handler():
await self._supervisor_ref.remove_worker(self.address)
os._exit(0)

loop = asyncio.get_running_loop()
loop.add_signal_handler(
signal.SIGINT, lambda: asyncio.create_task(signal_handler())
)

async def __pre_destroy__(self):
self._upload_task.cancel()
Expand Down
4 changes: 2 additions & 2 deletions xinference/model/llm/tests/test_llm_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import codecs
import json
import os
import shutil
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_builtin_llm_families():
json_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "..", "llm_family.json"
)
for json_obj in json.load(open(json_path)):
for json_obj in json.load(codecs.open(json_path, "r", encoding="utf-8")):
LLMFamilyV1.parse_obj(json_obj)


Expand Down

0 comments on commit 0bf90da

Please sign in to comment.