Re: [WebDNA] Some code inside a large loops fail ... but why?
This WebDNA talk-list message is from 2010
It keeps the original formatting.
numero = 104433
interpreted = N
texte = Text variables are retained in the spawned thread, but containing =context (loop, founditems, etc) status is not. So, you can set a text =variable to the loop's index value before beginning your spawn. For =example:[writefile test.txt][date] [time][/writefile][loop start=3D1&end=3D10][text]x=3D[index][/text][spawn][appendfile test.txt][x][/appendfile][/spawn][/loop]results in the file test.txt containing:01/12/2010 21:19:4912345678910Brian FriesBrainScan SoftwareOn Jan 12, 2010, at 9:13 PM, Kenneth Grome wrote:>> Looking at the docs for [spawn] I see that you may have to=20>> stagger (in time) those spawns since too many at once will=20>> weigh down the server too much).>=20> I tried spawn but the loop index was not passed into the spawn context =so the tcpconnect which needs that index fails. If it actually worked =the huge number of spawns would bring down my webdna server or the data =source server unle>=20> The best solution is really the simplest, but only if the tcpconnect =has a timeout or never fails. It is very simple to hit the server =consecutively with the code I already posted, and if the tcpconnect =never failed I could get all 300k records from that simple little bit of =code.>=20>=20>> Could you spawn/divide the task into batches so that if one=20>> tcpconnect fails then it will only spoil that one batch? =20>=20> Possibly, but first I would have to figure out how to pass the loop =index value into the spawn context, then I would have to figure out how =to create the groupings so that only a small number of tcpconnects were =spawned at one time. And then I would have to figure out how to control =the speed that each spawned thread is created so they are not all =spawned at once. As you can see this is very complicated compared with =the simple code I posted earlier.>=20> For now I'm using a meta-refresh in my browser to hit that same code =with a loop of only 10 records at a time. If the browser fails I will =know it because the page won't be returned, instead an error will be =displayed. Then I can easily look in the db to find the last record =appended and continue from there.>=20> The browser technique is possible only because I'm using it to =initially populate the db. It wouldn't be practical on a regular basis. = After the db gets populated initially, adding new records will be far =simpler. =20>=20> I was hoping to use tcpconnect to do the initial population but =without a timeout everything grinds to a halt with no warnings or =errors, and I don't think there is any way to create an error message =(or send an error email) once the tcpconnect has failed because as soon =as that happens no other code is processed.>=20> Sincerely,> Kenneth Grome> www.KenGrome.com>=20>=20>=20>=20>=20>=20> ---------------------------------------------------------> This message is sent to you because you are subscribed to> the mailing list
.> To unsubscribe, E-mail to: > archives: http://mail.webdna.us/list/talk@webdna.us> old archives: http://dev.webdna.us/TalkListArchive/> Bug Reporting: =http://forum.webdna.us/eucabb.html?page=3Dtopics&category=3D288
Associated Messages, from the most recent to the oldest:
Text variables are retained in the spawned thread, but containing =context (loop, founditems, etc) status is not. So, you can set a text =variable to the loop's index value before beginning your spawn. For =example:[writefile test.txt][date] [time][/writefile][loop start=3D1&end=3D10][text]x=3D[index][/text][spawn][appendfile test.txt][x][/appendfile][/spawn][/loop]results in the file test.txt containing:01/12/2010 21:19:4912345678910Brian FriesBrainScan SoftwareOn Jan 12, 2010, at 9:13 PM, Kenneth Grome wrote:>> Looking at the docs for [spawn] I see that you may have to=20>> stagger (in time) those spawns since too many at once will=20>> weigh down the server too much).>=20> I tried spawn but the loop index was not passed into the spawn context =so the tcpconnect which needs that index fails. If it actually worked =the huge number of spawns would bring down my webdna server or the data =source server unle>=20> The best solution is really the simplest, but only if the tcpconnect =has a timeout or never fails. It is very simple to hit the server =consecutively with the code I already posted, and if the tcpconnect =never failed I could get all 300k records from that simple little bit of =code.>=20>=20>> Could you spawn/divide the task into batches so that if one=20>> tcpconnect fails then it will only spoil that one batch? =20>=20> Possibly, but first I would have to figure out how to pass the loop =index value into the spawn context, then I would have to figure out how =to create the groupings so that only a small number of tcpconnects were =spawned at one time. And then I would have to figure out how to control =the speed that each spawned thread is created so they are not all =spawned at once. As you can see this is very complicated compared with =the simple code I posted earlier.>=20> For now I'm using a meta-refresh in my browser to hit that same code =with a loop of only 10 records at a time. If the browser fails I will =know it because the page won't be returned, instead an error will be =displayed. Then I can easily look in the db to find the last record =appended and continue from there.>=20> The browser technique is possible only because I'm using it to =initially populate the db. It wouldn't be practical on a regular basis. = After the db gets populated initially, adding new records will be far =simpler. =20>=20> I was hoping to use tcpconnect to do the initial population but =without a timeout everything grinds to a halt with no warnings or =errors, and I don't think there is any way to create an error message =(or send an error email) once the tcpconnect has failed because as soon =as that happens no other code is processed.>=20> Sincerely,> Kenneth Grome> www.KenGrome.com>=20>=20>=20>=20>=20>=20> ---------------------------------------------------------> This message is sent to you because you are subscribed to> the mailing list .> To unsubscribe, E-mail to: > archives: http://mail.webdna.us/list/talk@webdna.us> old archives: http://dev.webdna.us/TalkListArchive/> Bug Reporting: =http://forum.webdna.us/eucabb.html?page=3Dtopics&category=3D288
Brian Fries
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
UPS Quick Cost Calculator (1997)
Cookies (1999)
Shopping Cart ID (1998)
listfiles, moving files (1998)
[OT] iFrame (body) Q (2004)
OT Cookie limit (2001)
Pithy questions on webcommerce & siteedit (1997)
multi-paragraph fields (1997)
Quickie question on the email templates (1997)
Limiting user access to .tmpl files (1997)
question: search return in order (1997)
Webdna sends your serial number on Internet (2003)
[table] strange behaviour (2003)
[OT] Netscape Browser Window (2001)
Striping Characters (1998)
Reindexing a db with duplicate numbers... (1999)
Another question (1997)
Items XX to XX shown (1997)
SetHeader context (1998)
setting taxable to true (1997)