This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » symfony queue requests sent by a single browser session?
symfony queue requests sent by a single browser session? [message #72176] Thu, 12 February 2009 05:04 Go to next message
alex2  is currently offline alex2
Messages: 14
Registered: January 2009
Junior Member
Hi,

why i'm asking this? well, i'm facing a rather wierd problem.

sequence of events...

1. request dataImport action (slow data loading stuff) and it starts processing...
2. request other symfony actions and you have to wait until dataImport completes before these actions get processed.

i notice that if i use another browser (i.e. another session), i don't have to wait for dataImport to complete for my actions to be processed.

my guess is symfony does some kind of checks to make sure 1 session has only 1 active request being processed.

is it so? why? and can i disable this 'feature'?

btw, took my quite a while to realize this... so really appreciate some answers here.... too much black magik happening with symfony... Wink

Re: symfony queue requests sent by a single browser session? [message #77720 is a reply to message #72176 ] Mon, 04 May 2009 13:54 Go to previous messageGo to next message
tdslot  is currently offline tdslot
Messages: 8
Registered: July 2007
Junior Member
Hi Alex2,

Did you have found solution for slow INSERT of Doctrine ORM?

In this case I have over 3000 rows
foreach ($rows as $row)
{
$insert = new Emails();
$insert->name = $row['0'];
$insert->lastname = $row['1'];
$insert->email = $row['2'];
$insert->save();
$insert->free(TRUE);
}

but very slow insert in table.

Tadas
Re: symfony queue requests sent by a single browser session? [message #77723 is a reply to message #72176 ] Mon, 04 May 2009 14:10 Go to previous messageGo to next message
Rubino  is currently offline Rubino
Messages: 104
Registered: April 2009
Location: Barcelona
Senior Member
A quick way of implementing this is to implement a jobProcessControl table.

When you submit the job - you create an entry in the table and then check if there's an outstanding job (ie entry) before allowing them to perform some other action.

You'd need some robust coding though - you'll need to deal with issues should it be impossible to complete the job for some reason, records being left in the table, etc.

You'd also need to implement something that allows them to cancel a job (ie don't let your locking mechanism stop them Smile)


Virtual Machine for Symfony & Zend PHP Framworks
Website: http://www.sipx.ws
Support & Project tracker: http://trac.sipx.ws/projects/show/symfony-vm
Re: symfony queue requests sent by a single browser session? [message #77726 is a reply to message #77720 ] Mon, 04 May 2009 14:41 Go to previous messageGo to next message
Rubino  is currently offline Rubino
Messages: 104
Registered: April 2009
Location: Barcelona
Senior Member
@tdslot:
Assuming your using Doctrine then modify your emailsTable class to include something like:

	
       public function importRecord($thisData) {
		$t = Doctrine_Record::fromArray($thisData)
					->save();
	}
	
	public function importRecords($records) {
		foreach($records as $thisRecord) {
			$this->importRecord($thisRecord);
		}
	}


You can then use it by:
  MyEmailTable->importRecord(array(
            'name'=>$row[0],
            'lastname'=>$row[1],
            'email'=>$row[2]));


or, if you feel comfortable creating a properly formatted array of the data to load:

  MyEmailTable->importRecords($formattedArray);


Something along those lines should work.

With the latter approach - it would be best to create chunks of records.

Doctrine appears to support bulk-inserts but I've been able to find any documentation on how this is implemented.

[Updated on: Mon, 04 May 2009 14:42]


Virtual Machine for Symfony & Zend PHP Framworks
Website: http://www.sipx.ws
Support & Project tracker: http://trac.sipx.ws/projects/show/symfony-vm
Re: symfony queue requests sent by a single browser session? [message #77732 is a reply to message #77726 ] Mon, 04 May 2009 15:51 Go to previous messageGo to next message
tdslot  is currently offline tdslot
Messages: 8
Registered: July 2007
Junior Member
Sorry I do not understand how to use this

Quote:

You can then use it by:

MyEmailTable->importRecord(array(
'name'=>$row[0],
'lastname'=>$row[1],
'email'=>$row[2]));


I have some syntax error "MyEmailTable->importRecord"
I added to EmailTable.class.php file this line and in action I have sintax error, mybe I do simething wrong? Smile sorry if my queastion will be stupid Smile

Tadas
Re: symfony queue requests sent by a single browser session? [message #77740 is a reply to message #77732 ] Mon, 04 May 2009 17:57 Go to previous messageGo to next message
Rubino  is currently offline Rubino
Messages: 104
Registered: April 2009
Location: Barcelona
Senior Member
In the EmailTable.class.php you need to add the functions I listed.

Then from the code where you are creating the records (in your action?) where you had the loop to create the records - change the loop to use the lines (inside the loop itself):

MyEmailTable->importRecord(array(
'name'=>$row[0],
'lastname'=>$row[1],
'email'=>$row[2]));


What you're doing is creating a helper function in the EmailTable class that will insert the data for you quickly.

The first function I list is just a quick proxy for adding records - the second one allows you to send a batch of records to the function - which will then be created for you.


Virtual Machine for Symfony & Zend PHP Framworks
Website: http://www.sipx.ws
Support & Project tracker: http://trac.sipx.ws/projects/show/symfony-vm
Re: symfony queue requests sent by a single browser session? [message #77753 is a reply to message #77740 ] Mon, 04 May 2009 21:11 Go to previous messageGo to next message
tdslot  is currently offline tdslot
Messages: 8
Registered: July 2007
Junior Member
Hi Rubino,

So I did this as you suggest me but I got an error exception unknown method Sad

Sorry maybe my question is elementary but I still learning Smile
Re: symfony queue requests sent by a single browser session? [message #77757 is a reply to message #77753 ] Mon, 04 May 2009 22:09 Go to previous messageGo to next message
Rubino  is currently offline Rubino
Messages: 104
Registered: April 2009
Location: Barcelona
Senior Member
np - let's keep things simple.

Are you using Doctrine or Propel?


Virtual Machine for Symfony & Zend PHP Framworks
Website: http://www.sipx.ws
Support & Project tracker: http://trac.sipx.ws/projects/show/symfony-vm
Re: symfony queue requests sent by a single browser session? [message #77763 is a reply to message #77757 ] Mon, 04 May 2009 22:39 Go to previous messageGo to next message
tdslot  is currently offline tdslot
Messages: 8
Registered: July 2007
Junior Member
I using Doctrine.
Re: symfony queue requests sent by a single browser session? [message #77781 is a reply to message #77763 ] Tue, 05 May 2009 07:48 Go to previous messageGo to next message
tdslot  is currently offline tdslot
Messages: 8
Registered: July 2007
Junior Member
Her I attache image with my real usage of your example.
In MyAction
index.php/fa/1113/0/

And here class
index.php/fa/1114/0/

Re: symfony queue requests sent by a single browser session? [message #77825 is a reply to message #77781 ] Tue, 05 May 2009 20:12 Go to previous messageGo to next message
Rubino  is currently offline Rubino
Messages: 104
Registered: April 2009
Location: Barcelona
Senior Member
Wotcha,

The addressTable is a class with non-static methods - so in your action you'll need to create an instance to use it:

$addressTable = new AddressTable();

$addressTable->importAddress(...)...


Virtual Machine for Symfony & Zend PHP Framworks
Website: http://www.sipx.ws
Support & Project tracker: http://trac.sipx.ws/projects/show/symfony-vm
Re: symfony queue requests sent by a single browser session? [message #77832 is a reply to message #77825 ] Tue, 05 May 2009 22:26 Go to previous message
tdslot  is currently offline tdslot
Messages: 8
Registered: July 2007
Junior Member
so now i got error

Warning: Missing argument 1 for Doctrine_Table::__construct(), called in /usr/local/www/projects/ies/apps/invsend/modules/uploadfile/ actions/actions.class.php on line 60 and defined in /usr/local/share/pear/symfony/plugins/sfDoctrinePlugin/lib/v endor/doctrine/Doctrine/Table.php on line 218

Catchable fatal error: Argument 2 passed to Doctrine_Table::__construct() must be an instance of Doctrine_Connection, none given, called in /usr/local/www/projects/ies/apps/invsend/modules/uploadfile/ actions/actions.class.php on line 60 and defined in /usr/local/share/pear/symfony/plugins/sfDoctrinePlugin/lib/v endor/doctrine/Doctrine/Table.php on line 218
Previous Topic:Model Generation issue, running SQL Server 2005 [solved]
Next Topic:prevalidator
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software