PC Review


Reply
Thread Tools Rate Thread

distributed vba project - multiple thread / concurrent file access

 
 
chris_culley@yahoo.com
Guest
Posts: n/a
 
      14th Jun 2007
Hi,

I know that vba isn't really written to allow this, but it's the only
tool I've got available.

My monte carlo model takes four hours to run on a single machine. I
thought it would be a good idea to split the processing over several
machines.

I've set the model up so the number of simulations is split up, and
each machine takes a set of these and runs with them (each machine
takes a 'job'). So far so good.

To allocate which machine takes which job I've written the job names
in an excel file. The machines poll on this file until it is
available. Once they get it and open it they take a job (and set a
flag to say they've taken it), close the file and run with the job.

I use the following code for the polling (isFileOpen is a function I
fonud on the MS support site - similar to John Walkenbachs
fileIsOpen()) :

***

While (IsFileOpen(wbname))
' wait a short (random) time (up to ten seconds)
waitTime = Rnd() * 10
Debug.Print Now()
Application.Wait (Now + TimeValue("0:00:" & waitTime & ""))
DoEvents
Wend

' ok open the file, take a job etc....
workbook(wbname).open ......
***

Now, I'm really concerned about concurrency issues - since three
machines could theoretically all hit the isFileOpen at the same time
and attempt to open it (or set the same flags). This would cause any
number of difficult to solve problems.

Anyone got any ideas? is there a quicker (i.e. atomic) way to check
and open a file? can anyone think of someway of using locks on the
file? Any advice from someone who's tried similar?

Many thanks,

Chris

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      14th Jun 2007
I would expect the operating system to handle this.

--
Regards,
Tom Ogilvy

"(E-Mail Removed)" wrote:

> Hi,
>
> I know that vba isn't really written to allow this, but it's the only
> tool I've got available.
>
> My monte carlo model takes four hours to run on a single machine. I
> thought it would be a good idea to split the processing over several
> machines.
>
> I've set the model up so the number of simulations is split up, and
> each machine takes a set of these and runs with them (each machine
> takes a 'job'). So far so good.
>
> To allocate which machine takes which job I've written the job names
> in an excel file. The machines poll on this file until it is
> available. Once they get it and open it they take a job (and set a
> flag to say they've taken it), close the file and run with the job.
>
> I use the following code for the polling (isFileOpen is a function I
> fonud on the MS support site - similar to John Walkenbachs
> fileIsOpen()) :
>
> ***
>
> While (IsFileOpen(wbname))
> ' wait a short (random) time (up to ten seconds)
> waitTime = Rnd() * 10
> Debug.Print Now()
> Application.Wait (Now + TimeValue("0:00:" & waitTime & ""))
> DoEvents
> Wend
>
> ' ok open the file, take a job etc....
> workbook(wbname).open ......
> ***
>
> Now, I'm really concerned about concurrency issues - since three
> machines could theoretically all hit the isFileOpen at the same time
> and attempt to open it (or set the same flags). This would cause any
> number of difficult to solve problems.
>
> Anyone got any ideas? is there a quicker (i.e. atomic) way to check
> and open a file? can anyone think of someway of using locks on the
> file? Any advice from someone who's tried similar?
>
> Many thanks,
>
> Chris
>
>

 
Reply With Quote
 
chris_culley@yahoo.com
Guest
Posts: n/a
 
      14th Jun 2007
Yeah - I imagine it should do with making sure that only one file can
open another at the same time... the problem I'm thinking off is the
following:

- imagine index.xls is not open (and held on a network drive
somewhere).
- two machines test at the same time that it's not open (unlikely).
- both machines break out of the while loop.
- one machine is able to open the file (pbly not both, as you
suggest).
- the other machine is left in limbo - can't open the file, can't get
back on it's poll

Not sure if this could happen, though if it could it would be rare?



On Jun 14, 2:15 pm, Tom Ogilvy <TomOgi...@discussions.microsoft.com>
wrote:
> I would expect the operating system to handle this.
>
> --
> Regards,
> Tom Ogilvy
>
>
>
> "chris_cul...@yahoo.com" wrote:
> > Hi,

>
> > I know that vba isn't really written to allow this, but it's the only
> > tool I've got available.

>
> > My monte carlo model takes four hours to run on a single machine. I
> > thought it would be a good idea to split the processing over several
> > machines.

>
> > I've set the model up so the number of simulations is split up, and
> > each machine takes a set of these and runs with them (each machine
> > takes a 'job'). So far so good.

>
> > To allocate which machine takes which job I've written the job names
> > in an excel file. The machines poll on this file until it is
> > available. Once they get it and open it they take a job (and set a
> > flag to say they've taken it), close the file and run with the job.

>
> > I use the following code for the polling (isFileOpen is a function I
> > fonud on the MS support site - similar to John Walkenbachs
> > fileIsOpen()) :

>
> > ***

>
> > While (IsFileOpen(wbname))
> > ' wait a short (random) time (up to ten seconds)
> > waitTime = Rnd() * 10
> > Debug.Print Now()
> > Application.Wait (Now + TimeValue("0:00:" & waitTime & ""))
> > DoEvents
> > Wend

>
> > ' ok open the file, take a job etc....
> > workbook(wbname).open ......
> > ***

>
> > Now, I'm really concerned about concurrency issues - since three
> > machines could theoretically all hit the isFileOpen at the same time
> > and attempt to open it (or set the same flags). This would cause any
> > number of difficult to solve problems.

>
> > Anyone got any ideas? is there a quicker (i.e. atomic) way to check
> > and open a file? can anyone think of someway of using locks on the
> > file? Any advice from someone who's tried similar?

>
> > Many thanks,

>
> > Chris- Hide quoted text -

>
> - Show quoted text -



 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      14th Jun 2007
Dim bk as Workbook
Do
if not isfileopen( abc) then

set bk = nothing
On error resume next
set bk = workbooks.open("index.xls")
On Error goto 0
Else
'pause
end if

loop while bk is nothing

I haven't tried it, but I assume if you can't open the book it will raise an
error.

--
Regards,
Tom Ogilvy


"(E-Mail Removed)" wrote:

> Yeah - I imagine it should do with making sure that only one file can
> open another at the same time... the problem I'm thinking off is the
> following:
>
> - imagine index.xls is not open (and held on a network drive
> somewhere).
> - two machines test at the same time that it's not open (unlikely).
> - both machines break out of the while loop.
> - one machine is able to open the file (pbly not both, as you
> suggest).
> - the other machine is left in limbo - can't open the file, can't get
> back on it's poll
>
> Not sure if this could happen, though if it could it would be rare?
>
>
>
> On Jun 14, 2:15 pm, Tom Ogilvy <TomOgi...@discussions.microsoft.com>
> wrote:
> > I would expect the operating system to handle this.
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> >
> > "chris_cul...@yahoo.com" wrote:
> > > Hi,

> >
> > > I know that vba isn't really written to allow this, but it's the only
> > > tool I've got available.

> >
> > > My monte carlo model takes four hours to run on a single machine. I
> > > thought it would be a good idea to split the processing over several
> > > machines.

> >
> > > I've set the model up so the number of simulations is split up, and
> > > each machine takes a set of these and runs with them (each machine
> > > takes a 'job'). So far so good.

> >
> > > To allocate which machine takes which job I've written the job names
> > > in an excel file. The machines poll on this file until it is
> > > available. Once they get it and open it they take a job (and set a
> > > flag to say they've taken it), close the file and run with the job.

> >
> > > I use the following code for the polling (isFileOpen is a function I
> > > fonud on the MS support site - similar to John Walkenbachs
> > > fileIsOpen()) :

> >
> > > ***

> >
> > > While (IsFileOpen(wbname))
> > > ' wait a short (random) time (up to ten seconds)
> > > waitTime = Rnd() * 10
> > > Debug.Print Now()
> > > Application.Wait (Now + TimeValue("0:00:" & waitTime & ""))
> > > DoEvents
> > > Wend

> >
> > > ' ok open the file, take a job etc....
> > > workbook(wbname).open ......
> > > ***

> >
> > > Now, I'm really concerned about concurrency issues - since three
> > > machines could theoretically all hit the isFileOpen at the same time
> > > and attempt to open it (or set the same flags). This would cause any
> > > number of difficult to solve problems.

> >
> > > Anyone got any ideas? is there a quicker (i.e. atomic) way to check
> > > and open a file? can anyone think of someway of using locks on the
> > > file? Any advice from someone who's tried similar?

> >
> > > Many thanks,

> >
> > > Chris- Hide quoted text -

> >
> > - Show quoted text -

>
>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      15th Jun 2007
Chris,
I have seen a product that enables Excel to spread the workload over
available machines, co-ordinating the processing and results. I can't
remember its name now, but a Google search on suitable terms may bring it
up. No idea on cost or applicability to you.

Have you considered using ADO to query/update the WB. Not sure if it would
be better, but you would not have the IsOpen problem.

NickHK

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I know that vba isn't really written to allow this, but it's the only
> tool I've got available.
>
> My monte carlo model takes four hours to run on a single machine. I
> thought it would be a good idea to split the processing over several
> machines.
>
> I've set the model up so the number of simulations is split up, and
> each machine takes a set of these and runs with them (each machine
> takes a 'job'). So far so good.
>
> To allocate which machine takes which job I've written the job names
> in an excel file. The machines poll on this file until it is
> available. Once they get it and open it they take a job (and set a
> flag to say they've taken it), close the file and run with the job.
>
> I use the following code for the polling (isFileOpen is a function I
> fonud on the MS support site - similar to John Walkenbachs
> fileIsOpen()) :
>
> ***
>
> While (IsFileOpen(wbname))
> ' wait a short (random) time (up to ten seconds)
> waitTime = Rnd() * 10
> Debug.Print Now()
> Application.Wait (Now + TimeValue("0:00:" & waitTime & ""))
> DoEvents
> Wend
>
> ' ok open the file, take a job etc....
> workbook(wbname).open ......
> ***
>
> Now, I'm really concerned about concurrency issues - since three
> machines could theoretically all hit the isFileOpen at the same time
> and attempt to open it (or set the same flags). This would cause any
> number of difficult to solve problems.
>
> Anyone got any ideas? is there a quicker (i.e. atomic) way to check
> and open a file? can anyone think of someway of using locks on the
> file? Any advice from someone who's tried similar?
>
> Many thanks,
>
> Chris
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple users concurrent saving of different records in Access 2 CamieG Microsoft Access 3 20th Feb 2009 08:22 PM
How to set concurrent multiple user access on MS Access 2003? nie.jean@gmail.com Microsoft Access 1 23rd Mar 2007 11:02 AM
running asp.net project on distributed servers ozcankanbur@yahoo.com Microsoft ASP .NET 2 1st Sep 2006 10:32 AM
Can Access 2003 handle multiple, concurrent users? How many? =?Utf-8?B?REZJQ2hyaXM=?= Microsoft Access 7 1st Mar 2005 07:42 PM
Do you folks have a Distributed Computing Project? ImaginAsian General Discussion 5 22nd Mar 2002 03:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:34 AM.