Re: Problem with pyglet.resource.FileLocation in home folder

32 views
Skip to first unread message

Nathan

unread,
Mar 15, 2013, 12:18:47 AM3/15/13
to pyglet...@googlegroups.com
On Tue, Mar 12, 2013 at 1:31 PM, Dave Musicant <musi...@gmail.com> wrote:
Hey folks -

I noticed an wacky problem with that only manifests itself when I run a program from the top level of my home directory. (OS X Lion, Python 2.7, pyglet 1.1.4.):

import os
import pyglet

print __file__
dirname = os.path.dirname(__file__)
loc = pyglet.resource.FileLocation(dirname)

This program runs fine when it is located anywhere in my directory tree except precisely in my "root" home directory. When the file is there and I run it, the program hangs. When I stop it with a ctrl-c, I get the below error. Any idea what's going on?

Thanks...

--
Dave Musicant


No idea, sorry.  But that script (if you put it in a file) works fine on Mountain Lion (10.8.3) and the 1.2dev version from the repository.

~ Nathan 

Dave Musicant

unread,
Mar 15, 2013, 10:44:58 PM3/15/13
to pyglet...@googlegroups.com
I've discovered the problem, actually -- pyglet.resource.FileLocation seems to take an enormously long time when run from directories with a lot of subdirectories/files (such as my home directory). Can anyone clarify what's going on there? Should this be considered a bug?

Nathan

unread,
Mar 19, 2013, 11:32:38 AM3/19/13
to pyglet...@googlegroups.com
On Fri, Mar 15, 2013 at 8:44 PM, Dave Musicant <musi...@gmail.com> wrote:
I've discovered the problem, actually -- pyglet.resource.FileLocation seems to take an enormously long time when run from directories with a lot of subdirectories/files (such as my home directory). Can anyone clarify what's going on there? Should this be considered a bug?


I don't think that's the problem.  Take a look at the code for FileLocation (it's almost...no code at all)

class Location(object):
    def open(self, filename, mode='rb'):
        raise NotImplementedError('abstract')

class FileLocation(Location):
    def __init__(self, path):
        self.path = path

    def open(self, filename, mode='rb'):
        return open(os.path.join(self.path, filename), mode) 

~ Nathan

Dave Musicant

unread,
Mar 27, 2013, 6:46:23 PM3/27/13
to pyglet...@googlegroups.com, Nathan
Hi Nathan -

I see your point, and yet the problem occurs. This works fine:


==============================================================
$ cd temp
$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on
darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyglet
>>> loc = pyglet.resource.FileLocation('')
>>> print loc
<pyglet.resource.FileLocation object at 0x42fe10>
==============================================================


whereas this doesn't (the errors appear after I hit ctrl-c when I get
tired of waiting):

==============================================================
DMUSICAN56252:temp dmusican$ cd ~
DMUSICAN56252:~ dmusican$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on
darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyglet
>>> loc = pyglet.resource.FileLocation('')
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Python/2.7/site-packages/pyglet-1.1.4-py2.7.egg/pyglet/__init__.py",
line 306, in __getattr__
File
"/Library/Python/2.7/site-packages/pyglet-1.1.4-py2.7.egg/pyglet/resource.py",
line 680, in <module>
File
"/Library/Python/2.7/site-packages/pyglet-1.1.4-py2.7.egg/pyglet/resource.py",
line 291, in __init__
File
"/Library/Python/2.7/site-packages/pyglet-1.1.4-py2.7.egg/pyglet/resource.py",
line 335, in reindex
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 294, in walk
for x in walk(new_path, topdown, onerror, followlinks):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 284, in walk
if isdir(join(top, name)):
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py",
line 65, in join
for b in p:
KeyboardInterrupt
>>>
====================================================================

Wacky, isn't it?

--
Dave
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pyglet-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pyglet-users/83pe-B1J2EQ/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> pyglet-users...@googlegroups.com.
> To post to this group, send email to pyglet...@googlegroups.com.
> Visit this group at http://groups.google.com/group/pyglet-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
Reply all
Reply to author
Forward
0 new messages