Fox threading issues

The program shows the Linux like behaviour on Windows for me (locking up). I
use ruby 1.6.7 (2002-09-12) [i586-mswin32], obtained from
http://www.ruby-lang.org/~usa/mswin32/ruby-1.6.7-20020912-1586-mswin32.zip
and copied over the ruby directory installed by the Prag Prog windows
installer.

The lockups are caused by repeating the addTimeOuts. FXApp#addTimeOut is a
buggy method under FXRuby at present. Use ruby threads for repititious
control, avoid Fox timeouts like the plague.

Of course, I hope that Lyle can contradict me.

David Naseby

I’m attempting to create a file within a directory
structure that may or may not exist yet.

File.open(“tempdir/foo.txt”,“w”) fails seemingly
because the ‘tempdir’ directory does not yet exist.
Is this proper behavior? If the user wants to create
the FILE, why would File#open assume they wouldn’t
want to create the underlying directory as well?

Is there another method that WOULD go ahead and create
the directory for me?

Jason

David Naseby wrote:

The program shows the Linux like behaviour on Windows for me (locking up). I
use ruby 1.6.7 (2002-09-12) [i586-mswin32], obtained from
http://www.ruby-lang.org/~usa/mswin32/ruby-1.6.7-20020912-1586-mswin32.zip
and copied over the ruby directory installed by the Prag Prog windows
installer.

Threads are broken for the Windows version of Ruby 1.6.7. This has
always been true and will always be true. It is not, and never was, an
FXRuby bug. This bug is fixed in the CVS sources for Ruby 1.6.8 and Ruby
1.7.3.

The lockups are caused by repeating the addTimeOuts. FXApp#addTimeOut is a
buggy method under FXRuby at present. Use Ruby threads for repetitious
control, avoid Fox timeouts like the plague.

I think David is correct that something is wrong for FXApp#addTimeout,
although several of the FXRuby example programs use them without ever
locking up. One minor change that would eventually need to be made to
Steve’s program is to of course lock the mutex before resetting the
$count in the button’s command handler, i.e.

 button.connect(SEL_COMMAND) do
   $lock.synchronize { $count = 0 }
 end

I also found that if I increase the sleep time in the thread from zero
to some small-but-non-zero value (e.g. sleep 0.001) it seems to work OK
– not sure what that means yet.

Of course, I hope that Lyle can contradict me.

Me too :wink: I went ahead and put this on the bug list.

require ‘ftools’

File.mkdirs(‘tempdir’)

···

On Wed, 04 Dec 2002 08:50:28 +0900, Jason Persampieri wrote:

Is there another method that WOULD go ahead and create
the directory for me?

Hi,

I’m attempting to create a file within a directory
structure that may or may not exist yet.

File.open(“tempdir/foo.txt”,“w”) fails seemingly
because the ‘tempdir’ directory does not yet exist.
Is this proper behavior? If the user wants to create
the FILE, why would File#open assume they wouldn’t
want to create the underlying directory as well?

Is there another method that WOULD go ahead and create
the directory for me?

Put

require ‘ftools’
File.mkpath “tempdir”

or

require ‘fileutils’
FileUtils.mkpath “tempdir”

before “open”.

						matz.
···

In message “Creating directories with File.open” on 02/12/04, Jason Persampieri jason@persampieri.net writes:

Ah… I see that in the ‘Standard Library’ section
now. Thanks.

Out of curiosity… why wouldn’t something like this
be in by default? Not to mention, why wouldn’t ‘open’
just do this automatically if File::CREAT is set?

Jason

···

— Yukihiro Matsumoto matz@ruby-lang.org wrote:

Hi,

In message “Creating directories with File.open” > on 02/12/04, Jason Persampieri > jason@persampieri.net writes:

I’m attempting to create a file within a directory
structure that may or may not exist yet.

File.open(“tempdir/foo.txt”,“w”) fails seemingly
because the ‘tempdir’ directory does not yet exist.

Is this proper behavior? If the user wants to
create
the FILE, why would File#open assume they wouldn’t
want to create the underlying directory as well?

Is there another method that WOULD go ahead and
create
the directory for me?

Put

require ‘ftools’
File.mkpath “tempdir”

or

require ‘fileutils’
FileUtils.mkpath “tempdir”

before “open”.

  					matz.

Mostly, I think, because that’s just not the way it has traditionally been
done in UNIX-ish O/S’s.

For example, in the C library, the fopen/open functions don’t make non-existent
directories for you. You must create the directory first and then create
the file. For another example, the mkdir command will create non-existing parent
directories, but not by default. You have to specify the -p option.

···

On Wed, 04 Dec 2002 09:20:53 +0900, Jason Persampieri wrote:

Ah… I see that in the ‘Standard Library’ section
now. Thanks.

Out of curiosity… why wouldn’t something like this
be in by default? Not to mention, why wouldn’t ‘open’
just do this automatically if File::CREAT is set?

Jason

— Yukihiro Matsumoto matz@ruby-lang.org wrote:

Hi,

In message “Creating directories with File.open” >> on 02/12/04, Jason Persampieri >> jason@persampieri.net writes:

I’m attempting to create a file within a directory
structure that may or may not exist yet.

File.open(“tempdir/foo.txt”,“w”) fails seemingly
because the ‘tempdir’ directory does not yet exist.

Is this proper behavior? If the user wants to
create
the FILE, why would File#open assume they wouldn’t
want to create the underlying directory as well?

Is there another method that WOULD go ahead and
create
the directory for me?

Put

require ‘ftools’
File.mkpath “tempdir”

or

require ‘fileutils’
FileUtils.mkpath “tempdir”

before “open”.

  					matz.

Mostly because this is the way it has always been done. In the standard C
library, the fopen/open functions do not create directories for you when
you create a file. You must create the directory first and then create the
file in the directory.

The mkdir(1) command will make non-existing parent directories for you,
but not by default. You must use the -p option.

···

On Wed, 04 Dec 2002 09:20:53 +0900, Jason Persampieri wrote:

Ah… I see that in the ‘Standard Library’ section now. Thanks.

Out of curiosity… why wouldn’t something like this be in by default?
Not to mention, why wouldn’t ‘open’ just do this automatically if
File::CREAT is set?

Jason

— Yukihiro Matsumoto matz@ruby-lang.org wrote:

Hi,

In message “Creating directories with File.open” >> on 02/12/04, Jason Persampieri >> jason@persampieri.net writes:

I’m attempting to create a file within a directory structure that may
or may not exist yet.

File.open(“tempdir/foo.txt”,“w”) fails seemingly because the ‘tempdir’
directory does not yet exist.

Is this proper behavior? If the user wants to
create
the FILE, why would File#open assume they wouldn’t want to create the
underlying directory as well?

Is there another method that WOULD go ahead and
create
the directory for me?

Put

require ‘ftools’
File.mkpath “tempdir”

or

require ‘fileutils’
FileUtils.mkpath “tempdir”

before “open”.

  					matz.