#30603: Stored file locking issue when using Django on Windows with the 
youtube_dl
package installed
-------------------------------------+-------------------------------------
     Reporter:  ManicEatsWorld       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  File                 |                  Version:  2.2
  uploads/storage                    |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by ManicEatsWorld:

Old description:

> When using the FileSystemStorage.save() functions in a Windows
> installation of Django with the [https://github.com/ytdl-org/youtube-dl/
> youtube_dl] package installed, an error is thrown in locks.py upon trying
> to unlock the newly stored file:
>
> {{{
> #!div style="font-size: 80%"
> {{{#!python
>   Internal Server Error: /
> Traceback (most recent call last):
>   File "<<Project base directory removed for privacy>>\venv\lib\site-
> packages\django\core\files\move.py", line 61, in file_move_safe
>     locks.lock(fd, locks.LOCK_EX)
>   File "<<Project base directory removed for privacy>>\venv\lib\site-
> packages\django\core\files\locks.py", line 80, in lock
>     ret = LockFileEx(hfile, flags, 0, 0, 0xFFFF0000, byref(overlapped))
> ctypes.ArgumentError: argument 6: <class 'TypeError'>: expected
> LP_OVERLAPPED instance instead of pointer to OVERLAPPED
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "<<Project base directory removed for privacy>>\venv\lib\site-
> packages\django\core\handlers\exception.py", line 34, in inner
>     response = get_response(request)
>   File "<<Project base directory removed for privacy>>\venv\lib\site-
> packages\django\core\handlers\base.py", line 115, in _get_response
>     response = self.process_exception_by_middleware(e, request)
>   File "<<Project base directory removed for privacy>>\venv\lib\site-
> packages\django\core\handlers\base.py", line 113, in _get_response
>     response = wrapped_callback(request, *callback_args,
> **callback_kwargs)
>   File "<<Project base directory removed for
> privacy>>\GenreClassificationWeb\webClassification\views.py", line 29, in
> upload
>     name = fs.save(uploaded_file.name, uploaded_file)
>   File "<<Project base directory removed for privacy>>\venv\lib\site-
> packages\django\core\files\storage.py", line 52, in save
>     return self._save(name, content)
>   File "<<Project base directory removed for privacy>>\venv\lib\site-
> packages\django\core\files\storage.py", line 261, in _save
>     file_move_safe(content.temporary_file_path(), full_path)
>   File "<<Project base directory removed for privacy>>\venv\lib\site-
> packages\django\core\files\move.py", line 67, in file_move_safe
>     locks.unlock(fd)
>   File " <<Project Directory>>\venv\lib\site-
> packages\django\core\files\locks.py", line 86, in unlock
>     ret = UnlockFileEx(hfile, 0, 0, 0xFFFF0000, byref(overlapped))
> ctypes.ArgumentError: argument 5: <class 'TypeError'>: expected
> LP_OVERLAPPED instance instead of pointer to OVERLAPPED
> }}}
> }}}
>
> Removing the youtube_dl package does immediately resolve this issue.
> Sadly, youtube-dl is necessary for this project due to a lack of working
> cross-platform alternatives.\\\\
>
> This issue has been recreated with a Windows 10 and a Windows 7 machine
> using different VENVs.\\\\
>
> I do believe this is a bug and will cross-post an issue at the youtube-dl
> [https://github.com/ytdl-org/youtube-dl/issues/ issue page].

New description:

 When using the FileSystemStorage.save() functions in a Windows
 installation of Django with the [https://github.com/ytdl-org/youtube-dl/
 youtube_dl] package installed, an error is thrown in locks.py upon trying
 to unlock the newly stored file:

 {{{
 #!div style="font-size: 80%"
 {{{#!python
   Internal Server Error: /
 Traceback (most recent call last):
   File "<<Project base directory removed for privacy>>\venv\lib\site-
 packages\django\core\files\move.py", line 61, in file_move_safe
     locks.lock(fd, locks.LOCK_EX)
   File "<<Project base directory removed for privacy>>\venv\lib\site-
 packages\django\core\files\locks.py", line 80, in lock
     ret = LockFileEx(hfile, flags, 0, 0, 0xFFFF0000, byref(overlapped))
 ctypes.ArgumentError: argument 6: <class 'TypeError'>: expected
 LP_OVERLAPPED instance instead of pointer to OVERLAPPED

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "<<Project base directory removed for privacy>>\venv\lib\site-
 packages\django\core\handlers\exception.py", line 34, in inner
     response = get_response(request)
   File "<<Project base directory removed for privacy>>\venv\lib\site-
 packages\django\core\handlers\base.py", line 115, in _get_response
     response = self.process_exception_by_middleware(e, request)
   File "<<Project base directory removed for privacy>>\venv\lib\site-
 packages\django\core\handlers\base.py", line 113, in _get_response
     response = wrapped_callback(request, *callback_args,
 **callback_kwargs)
   File "<<Project base directory removed for
 privacy>>\GenreClassificationWeb\webClassification\views.py", line 29, in
 upload
     name = fs.save(uploaded_file.name, uploaded_file)
   File "<<Project base directory removed for privacy>>\venv\lib\site-
 packages\django\core\files\storage.py", line 52, in save
     return self._save(name, content)
   File "<<Project base directory removed for privacy>>\venv\lib\site-
 packages\django\core\files\storage.py", line 261, in _save
     file_move_safe(content.temporary_file_path(), full_path)
   File "<<Project base directory removed for privacy>>\venv\lib\site-
 packages\django\core\files\move.py", line 67, in file_move_safe
     locks.unlock(fd)
   File " <<Project Directory>>\venv\lib\site-
 packages\django\core\files\locks.py", line 86, in unlock
     ret = UnlockFileEx(hfile, 0, 0, 0xFFFF0000, byref(overlapped))
 ctypes.ArgumentError: argument 5: <class 'TypeError'>: expected
 LP_OVERLAPPED instance instead of pointer to OVERLAPPED
 }}}
 }}}

 Removing the youtube_dl package does immediately resolve this issue.
 Sadly, youtube-dl is necessary for this project due to a lack of working
 cross-platform alternatives.\\\\

 This issue has been recreated with a Windows 10 and a Windows 7 machine
 using different VENVs.\\\\

 I do believe this is a bug and have cross-posted an issue at the youtube-
 dl issue page: https://github.com/ytdl-org/youtube-dl/issues/21545.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30603#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/071.09ab53ea618c8d1cb1b5058fbfe0d402%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to