Skip to content

Commit

Permalink
fix: sandbox not working on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
mciissee committed Mar 1, 2021
1 parent f3b2a5e commit cc9a63a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
13 changes: 8 additions & 5 deletions pl_sandbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@

import logging
import os
import shutil
import sys
import threading
import time
import platform

import docker

from sandbox.container import initialise_container

Expand Down Expand Up @@ -58,6 +56,11 @@
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Logger information
LOGGER_ADDRESS = '/dev/log'
if platform.system() == 'Darwin':
# https://docs.python.org/3/library/logging.handlers.html#sysloghandler
LOGGER_ADDRESS = '/var/run/syslog'

LOGGING = {
'version' : 1,
'disable_existing_loggers': False,
Expand Down Expand Up @@ -91,15 +94,15 @@
'level' : 'INFO',
'class' : 'logging.handlers.SysLogHandler',
'facility' : 'local6',
'address' : '/dev/log',
'address' : LOGGER_ADDRESS,
'formatter': 'verbose',
'filters' : ['require_debug_false'],
},
'syslog_debug': {
'level' : 'DEBUG',
'class' : 'logging.handlers.SysLogHandler',
'facility' : 'local6',
'address' : '/dev/log',
'address' : LOGGER_ADDRESS,
'formatter': 'verbose',
'filters' : ['require_debug_true'],
},
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Django>=2.1.0,<3.0.0
docker
pytz
requests
timeout-decorator
wrapt_timeout_decorator
6 changes: 3 additions & 3 deletions sandbox/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import time
import traceback

import timeout_decorator
from django.conf import settings

from sandbox.enums import SandboxErrCode
from sandbox.exceptions import ContextNotFoundError, GraderError
from wrapt_timeout_decorator import *


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -118,7 +118,7 @@ def get_context(self):
return j


@timeout_decorator.timeout(BUILD_TIMEOUT, use_signals=False)
@timeout(BUILD_TIMEOUT, use_signals=False)
def build(self):
"""Execute builder.py."""
start = time.time()
Expand Down Expand Up @@ -210,7 +210,7 @@ def get_context(self):
return j


@timeout_decorator.timeout(EVAL_TIMEOUT, use_signals=False)
@timeout(EVAL_TIMEOUT, use_signals=False)
def evaluate(self):
"""Execute grader.py, returning the result. """
start = time.time()
Expand Down

0 comments on commit cc9a63a

Please sign in to comment.