0

Os: Windows 10 python: 3.8

Hello, I know there are several versions of the same error here (does not match the criteria), here (not answered), here (irrelevant and not answered) and is actually registered as python bug here but I can't find a solution that solves the problem. This code runs perfectly fine on my macbook pro and most probably will run without problems on linux, however I don't have a windows pc to test it and I need to, so when I run it through a friend's pc(which I do not have physical access to and I'm unable to debug the code myself) the code executes and does all the tasks it's expected to do, however by the time the code is exiting(after everything executes successfully in the browser), the error occurs therefore, I will not include the whole code, just the main() & __main__ guard.

def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--base_url',
        help='start url',
        default='https://opensource-demo.orangehrmlive.com',
    )
    parser.add_argument('--username', help='login username', default='Admin')
    parser.add_argument('--password', help='login password', default='admin123')
    parser.add_argument('--name', help='employee name field', required=True)
    parser.add_argument('--leave_type', help='leave type field', required=True)
    parser.add_argument('--from_date', help='from date field', required=True)
    parser.add_argument('--to_date', help='to date field', required=True)
    parser.add_argument('--partial_days', help='partial days field', default='None')
    parser.add_argument(
        '--comment', help='assign leave comment', default='- Not required -'
    )
    parser.add_argument('--logout', help='logout after ', type=int, default=1)
    cli_args = parser.parse_args(argv)
    logger = get_logger()
    driver = login(cli_args.base_url, logger, cli_args.username, cli_args.password)
    submit_leave_form(
        driver,
        logger,
        cli_args.name,
        cli_args.leave_type,
        cli_args.from_date,
        cli_args.to_date,
        cli_args.partial_days,
        cli_args.comment,
        cli_args.logout,
    )


if __name__ == '__main__':
    main(sys.argv[1:])

Error:

DevTools listening on ws://127.0.0.1:57815/devtools/browser/66dd41c3-c3c9-455e-9a84-4347b146e562
2020-09-30 18:19:39,395 API Extractor: WARNING Overlapping dates for Jasmine Morgan
2020-10-19 | 2020-10-20 | 2020-10-21 | 2020-10-22 | 2020-10-23
Exception ignored in: <function Popen.__del__ at 0x03727F58>
Traceback (most recent call last):
  File "C:\Users\Ghandour\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 945, in _del_
    self._internal_poll(_deadstate=_maxsize)
  File "C:\Users\Ghandour\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1344, in _internal_poll
    if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] The handle is invalid
  • is this IEDriver? – pcalkins Sep 29 '20 at 23:12
  • I don't know what this is so, no –  Sep 30 '20 at 03:27
  • does a browser launch? – pcalkins Sep 30 '20 at 17:33
  • Yes, and it finishes all the tasks it's expected to do then the error occurs at exit. I looked on github, it looks like there is a bug in `subprocess.py` that causes the issue, which needs manual editing and since it's not my pc as i mentioned earlier, i'll try as soon as the windows pc is available / a solution is suggested here –  Sep 30 '20 at 19:03
  • sry, I thought you'd mention it, but which browser launches? – pcalkins Sep 30 '20 at 19:04
  • Google chrome.. –  Sep 30 '20 at 19:12
  • include your calls that dispose of the driver instance. It looks like something is waiting on a process that no longer exists.... "WaitForSingleObject" is a Windows call: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject – pcalkins Sep 30 '20 at 20:03
  • I tried with and without `driver.close()` at the end of `main()` but still, the problem remains –  Oct 01 '20 at 03:20
  • you'll want driver.quit() to close both browser and driver. Using close() will only close a browser window. – pcalkins Oct 01 '20 at 16:59

0 Answers0