"Sleep" function in COM API

Use this forum if you want to suggest a new feature to hMailServer. Before posting, please search the forum to confirm that it has not already been suggested.
Post Reply

Do you want/need this?

YES!
2
22%
NO!
7
78%
 
Total votes: 9

amokkaths
New user
New user
Posts: 15
Joined: 2012-04-19 22:20

"Sleep" function in COM API

Post by amokkaths » 2012-05-30 15:59

It would be nice to include kernel32.dll sleep function to work in COM API in "Utilities" or another place for using in VBS scripting. There is no WScript object in hMailServer environment, thus it is impossible to use "WScript.Sleep". I think many people will find "sleep" function very useful, like me.
For example I need to run WScript.Exec function and wait for process to terminate, to get ExitCode.

MOD EDIT: Poll added

User avatar
BOOZy
Normal user
Normal user
Posts: 80
Joined: 2006-05-25 01:25
Location: .nl
Contact:

Re: "Sleep" function in COM API

Post by BOOZy » 2012-05-30 19:22

Why would you want to slow down your mail threads, potentially killing your server?

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: "Sleep" function in COM API

Post by ^DooM^ » 2012-05-30 19:23

Indeed this could potentially cripple your server especially if sleep is blocking.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

amokkaths
New user
New user
Posts: 15
Joined: 2012-04-19 22:20

Re: "Sleep" function in COM API

Post by amokkaths » 2012-05-30 19:27

I explained in the end of my post. I need to wait for launched process to finish and get the exit code.

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: "Sleep" function in COM API

Post by ^DooM^ » 2012-05-30 19:33

yes and when your server receives 100 emails and it sits there waiting for the exit code, your server will sit there doing nothing at all, not even accepting new email and tying up your CPU with redundant sleep cycles. Expect huge CPU spikes.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

amokkaths
New user
New user
Posts: 15
Joined: 2012-04-19 22:20

Re: "Sleep" function in COM API

Post by amokkaths » 2012-05-30 19:47

You are wrong. I need "sleep" to avoid high CPU usage. Sleep uses 0% of CPU. Process launched will exit after 0.25-2 seconds, it is known. But I need to wait that time without empty "while...do" loops, which WILL cause 100% CPU spikes. That is difference.

User avatar
dzekas
Senior user
Senior user
Posts: 2486
Joined: 2005-10-13 21:28
Location: Lithuania

Re: "Sleep" function in COM API

Post by dzekas » 2012-05-30 20:02

BOOZy wrote:Why would you want to slow down your mail threads, potentially killing your server?
It is one of programming methods for running detached processes or for running something that must be stopped within specified time frame regardless of execution results. If you continue running slow process until it finishes, you can impact overall execution of your task.

The only weird thing is that programming language does not have native function for that or it is not working in script environment.
Last edited by dzekas on 2012-05-30 20:13, edited 1 time in total.

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: "Sleep" function in COM API

Post by ^DooM^ » 2012-05-30 20:11

amokkaths wrote:You are wrong. I need "sleep" to avoid high CPU usage. Sleep uses 0% of CPU. Process launched will exit after 0.25-2 seconds, it is known. But I need to wait that time without empty "while...do" loops, which WILL cause 100% CPU spikes. That is difference.
hMail source is on SVN, have at it :)
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

amokkaths
New user
New user
Posts: 15
Joined: 2012-04-19 22:20

Re: "Sleep" function in COM API

Post by amokkaths » 2012-05-30 20:15

I thought it is feature request thread.......

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: "Sleep" function in COM API

Post by Bill48105 » 2012-05-30 20:16

amokkaths wrote:I thought it is feature request thread.......
It is, check out the poll results. Not looking good so far but early I suppose. :D
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

rolaids0
Normal user
Normal user
Posts: 150
Joined: 2010-04-27 02:03
Location: Florida
Contact:

Re: "Sleep" function in COM API

Post by rolaids0 » 2012-05-30 21:46

The answer takes some creativity (Google shows that sleep will probably NEVER be included into hmail, Martin said as much (more words))

To sleep (which will break things, but you don't seem to care) create a vbs file with just:
WScript.Sleep 1000

each "loop" call that using cscript (with wscript.shell.run):
http://technet.microsoft.com/en-us/libr ... 56605.aspx

call C:\Windows\System32\cscript.exe //NoLogo "path\to\script\with\sleep\script.vbs"

amokkaths
New user
New user
Posts: 15
Joined: 2012-04-19 22:20

Re: "Sleep" function in COM API

Post by amokkaths » 2012-05-30 21:54

rolaids0 wrote: call C:\Windows\System32\cscript.exe //NoLogo "path\to\script\with\sleep\script.vbs"
I have seen this solution too, but calling cscript will make unnecessary load and delay.
So I am voting for native, fast "sleep".

rolaids0
Normal user
Normal user
Posts: 150
Joined: 2010-04-27 02:03
Location: Florida
Contact:

Re: "Sleep" function in COM API

Post by rolaids0 » 2012-05-30 21:57

You can Google "hmailserver wscript.sleep" and will see (from the Dev: Martin) ain't gonna happen for far too many technical reasons.

Your solution here is to:
1) Use my proposed solution (which you don't like.)
2) Download the hmailserver source, and add it in yourself (which you don't seem to want to do.)
3) Do nothing, and live with it the way it is (or do something without sleep.)

What are you running that requires a return code?

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: "Sleep" function in COM API

Post by ^DooM^ » 2012-05-30 22:08

amokkaths wrote:I thought it is feature request thread.......
Read this http://www.hmailserver.com/documentatio ... ementation
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

amokkaths
New user
New user
Posts: 15
Joined: 2012-04-19 22:20

Re: "Sleep" function in COM API

Post by amokkaths » 2012-05-30 22:29

rolaids0,
Yes, I am lazy :D Adding that "sleep" is not so hard. Hardest part is to set up compiling environment, to find out where to put the things etc. But I will try.

Thank everyone for participating.

User avatar
WolfWare
New user
New user
Posts: 4
Joined: 2013-01-09 03:24

Re: "Sleep" function in COM API

Post by WolfWare » 2013-01-22 02:08

Zzzzzzz... Oh, sorry! I dozed off there - lack of sleep! :D

Late to the party, but I do have a scenario/question. Local ISP's tend to throttle email distribution lists, especially home sent ones. A SPAM policing clunky approach, but I guess they have to do what they do.

Anyhow, my ISP's drops mail-burst distributions around the 20th recipient, BUT... here comes the rub ...when I add a random sleep delay between each post, my ISP's mail-storm filters are less prone to alarm at my alarming distribution (or should that be disposition). :shock:

I'll put my old-bird into a dive now to avoid being shot down... merrrrang, scaplaracrash, boom!

WW (lucky I packed that parachute).

User avatar
mattg
Moderator
Moderator
Posts: 20841
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: "Sleep" function in COM API

Post by mattg » 2013-01-22 15:20

In SMTP >> Advanced there is a maximum recipients in batch setting. This does exactly as you wish, ie only sends to a maximum number of recipients per domain
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

DavidB
Normal user
Normal user
Posts: 122
Joined: 2008-11-03 06:48

Re: "Sleep" function in COM API

Post by DavidB » 2013-01-23 07:30

Have a look at this link
http://www.vistax64.com/vb-script/17460 ... inish.html

If that doesn't help, try googling for some Wscript information rather than waiting for a feature to be added, because what Martin says goes :)

Post Reply